From 3e6a3548b867a894510654cd931e4ccd44b795e5 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Thu, 15 Dec 2022 07:03:24 +0000 Subject: [PATCH] CodeGen from PR 20725 in Azure/azure-rest-api-specs Service Bus API version 2022-10-01-preview (#20725) * Base Checkin * update API version to 2022-10-01-preview * Adding the partition count property * updated readme files * Changed the name of the partitions property to premiumMessagingPartitions * added headers - azure-asyncoperation * revertd changes for "modelAsString": true * revertign the modelasstring changes * ci Fixes Co-authored-by: REDMOND\ardsouza Co-authored-by: Ajit Maruti Navasare (MINDTREE LIMITED) Co-authored-by: Ajit Navasare --- .../azure-mgmt-servicebus/_meta.json | 12 +- .../azure/mgmt/servicebus/__init__.py | 4 + .../azure/mgmt/servicebus/_configuration.py | 18 +- .../azure/mgmt/servicebus/_serialization.py | 1967 ++++++++++ .../_service_bus_management_client.py | 70 +- .../mgmt/servicebus/aio/_configuration.py | 6 +- .../aio/_service_bus_management_client.py | 57 +- .../mgmt/servicebus/v2015_08_01/__init__.py | 7 +- .../servicebus/v2015_08_01/_configuration.py | 51 +- .../servicebus/v2015_08_01/_metadata.json | 24 +- .../mgmt/servicebus/v2015_08_01/_patch.py | 1 + .../_service_bus_management_client.py | 56 +- .../mgmt/servicebus/v2015_08_01/_vendor.py | 6 +- .../mgmt/servicebus/v2015_08_01/_version.py | 2 +- .../servicebus/v2015_08_01/aio/__init__.py | 7 +- .../v2015_08_01/aio/_configuration.py | 50 +- .../mgmt/servicebus/v2015_08_01/aio/_patch.py | 1 + .../aio/_service_bus_management_client.py | 47 +- .../v2015_08_01/aio/operations/__init__.py | 15 +- .../aio/operations/_namespaces_operations.py | 1131 ++++-- .../v2015_08_01/aio/operations/_operations.py | 82 +- .../v2015_08_01/aio/operations/_patch.py | 1 + .../aio/operations/_queues_operations.py | 814 +++-- .../operations/_subscriptions_operations.py | 329 +- .../aio/operations/_topics_operations.py | 814 +++-- .../servicebus/v2015_08_01/models/__init__.py | 94 +- .../v2015_08_01/models/_models_py3.py | 971 +++-- .../servicebus/v2015_08_01/models/_patch.py | 1 + .../_service_bus_management_client_enums.py | 29 +- .../v2015_08_01/operations/__init__.py | 15 +- .../operations/_namespaces_operations.py | 1656 +++++---- .../v2015_08_01/operations/_operations.py | 109 +- .../v2015_08_01/operations/_patch.py | 1 + .../operations/_queues_operations.py | 1239 ++++--- .../operations/_subscriptions_operations.py | 476 +-- .../operations/_topics_operations.py | 1239 ++++--- .../mgmt/servicebus/v2017_04_01/__init__.py | 7 +- .../servicebus/v2017_04_01/_configuration.py | 51 +- .../servicebus/v2017_04_01/_metadata.json | 24 +- .../mgmt/servicebus/v2017_04_01/_patch.py | 1 + .../_service_bus_management_client.py | 82 +- .../mgmt/servicebus/v2017_04_01/_vendor.py | 6 +- .../mgmt/servicebus/v2017_04_01/_version.py | 2 +- .../servicebus/v2017_04_01/aio/__init__.py | 7 +- .../v2017_04_01/aio/_configuration.py | 50 +- .../mgmt/servicebus/v2017_04_01/aio/_patch.py | 1 + .../aio/_service_bus_management_client.py | 73 +- .../v2017_04_01/aio/operations/__init__.py | 27 +- .../_disaster_recovery_configs_operations.py | 691 ++-- .../aio/operations/_event_hubs_operations.py | 93 +- .../_migration_configs_operations.py | 458 ++- .../aio/operations/_namespaces_operations.py | 1477 +++++--- .../v2017_04_01/aio/operations/_operations.py | 82 +- .../v2017_04_01/aio/operations/_patch.py | 1 + .../_premium_messaging_regions_operations.py | 83 +- .../aio/operations/_queues_operations.py | 769 ++-- .../aio/operations/_regions_operations.py | 89 +- .../aio/operations/_rules_operations.py | 328 +- .../operations/_subscriptions_operations.py | 327 +- .../aio/operations/_topics_operations.py | 769 ++-- .../servicebus/v2017_04_01/models/__init__.py | 162 +- .../v2017_04_01/models/_models_py3.py | 1324 +++---- .../servicebus/v2017_04_01/models/_patch.py | 1 + .../_service_bus_management_client_enums.py | 49 +- .../v2017_04_01/operations/__init__.py | 27 +- .../_disaster_recovery_configs_operations.py | 1082 +++--- .../operations/_event_hubs_operations.py | 136 +- .../_migration_configs_operations.py | 677 ++-- .../operations/_namespaces_operations.py | 2183 ++++++----- .../v2017_04_01/operations/_operations.py | 109 +- .../v2017_04_01/operations/_patch.py | 1 + .../_premium_messaging_regions_operations.py | 118 +- .../operations/_queues_operations.py | 1168 +++--- .../operations/_regions_operations.py | 129 +- .../operations/_rules_operations.py | 485 ++- .../operations/_subscriptions_operations.py | 478 +-- .../operations/_topics_operations.py | 1168 +++--- .../v2018_01_01_preview/__init__.py | 7 +- .../v2018_01_01_preview/_configuration.py | 51 +- .../v2018_01_01_preview/_metadata.json | 24 +- .../servicebus/v2018_01_01_preview/_patch.py | 1 + .../_service_bus_management_client.py | 84 +- .../servicebus/v2018_01_01_preview/_vendor.py | 6 +- .../v2018_01_01_preview/_version.py | 2 +- .../v2018_01_01_preview/aio/__init__.py | 7 +- .../v2018_01_01_preview/aio/_configuration.py | 50 +- .../v2018_01_01_preview/aio/_patch.py | 1 + .../aio/_service_bus_management_client.py | 75 +- .../aio/operations/__init__.py | 31 +- .../_disaster_recovery_configs_operations.py | 792 ++-- .../aio/operations/_event_hubs_operations.py | 95 +- .../_migration_configs_operations.py | 475 ++- .../aio/operations/_namespaces_operations.py | 2104 +++++++---- .../aio/operations/_operations.py | 84 +- .../aio/operations/_patch.py | 1 + .../_premium_messaging_regions_operations.py | 85 +- ...private_endpoint_connections_operations.py | 384 +- .../_private_link_resources_operations.py | 64 +- .../aio/operations/_queues_operations.py | 790 ++-- .../aio/operations/_regions_operations.py | 91 +- .../aio/operations/_rules_operations.py | 335 +- .../operations/_subscriptions_operations.py | 335 +- .../aio/operations/_topics_operations.py | 790 ++-- .../v2018_01_01_preview/models/__init__.py | 202 +- .../v2018_01_01_preview/models/_models_py3.py | 1575 ++++---- .../v2018_01_01_preview/models/_patch.py | 1 + .../_service_bus_management_client_enums.py | 61 +- .../operations/__init__.py | 31 +- .../_disaster_recovery_configs_operations.py | 1232 ++++--- .../operations/_event_hubs_operations.py | 141 +- .../_migration_configs_operations.py | 718 ++-- .../operations/_namespaces_operations.py | 3195 ++++++++++------- .../operations/_operations.py | 114 +- .../v2018_01_01_preview/operations/_patch.py | 1 + .../_premium_messaging_regions_operations.py | 124 +- ...private_endpoint_connections_operations.py | 555 +-- .../_private_link_resources_operations.py | 108 +- .../operations/_queues_operations.py | 1229 ++++--- .../operations/_regions_operations.py | 133 +- .../operations/_rules_operations.py | 510 +-- .../operations/_subscriptions_operations.py | 501 +-- .../operations/_topics_operations.py | 1229 ++++--- .../v2021_01_01_preview/__init__.py | 7 +- .../v2021_01_01_preview/_configuration.py | 51 +- .../v2021_01_01_preview/_metadata.json | 24 +- .../servicebus/v2021_01_01_preview/_patch.py | 1 + .../_service_bus_management_client.py | 73 +- .../servicebus/v2021_01_01_preview/_vendor.py | 6 +- .../v2021_01_01_preview/_version.py | 2 +- .../v2021_01_01_preview/aio/__init__.py | 7 +- .../v2021_01_01_preview/aio/_configuration.py | 50 +- .../v2021_01_01_preview/aio/_patch.py | 1 + .../aio/_service_bus_management_client.py | 64 +- .../aio/operations/__init__.py | 25 +- .../_disaster_recovery_configs_operations.py | 792 ++-- .../_migration_configs_operations.py | 475 ++- .../aio/operations/_namespaces_operations.py | 1404 +++++--- .../aio/operations/_operations.py | 84 +- .../aio/operations/_patch.py | 1 + ...private_endpoint_connections_operations.py | 384 +- .../_private_link_resources_operations.py | 64 +- .../aio/operations/_queues_operations.py | 790 ++-- .../aio/operations/_rules_operations.py | 335 +- .../operations/_subscriptions_operations.py | 335 +- .../aio/operations/_topics_operations.py | 790 ++-- .../v2021_01_01_preview/models/__init__.py | 180 +- .../v2021_01_01_preview/models/_models_py3.py | 1422 ++++---- .../v2021_01_01_preview/models/_patch.py | 1 + .../_service_bus_management_client_enums.py | 57 +- .../operations/__init__.py | 25 +- .../_disaster_recovery_configs_operations.py | 1232 ++++--- .../_migration_configs_operations.py | 718 ++-- .../operations/_namespaces_operations.py | 2095 ++++++----- .../operations/_operations.py | 114 +- .../v2021_01_01_preview/operations/_patch.py | 1 + ...private_endpoint_connections_operations.py | 555 +-- .../_private_link_resources_operations.py | 108 +- .../operations/_queues_operations.py | 1229 ++++--- .../operations/_rules_operations.py | 510 +-- .../operations/_subscriptions_operations.py | 501 +-- .../operations/_topics_operations.py | 1229 ++++--- .../v2021_06_01_preview/__init__.py | 7 +- .../v2021_06_01_preview/_configuration.py | 51 +- .../v2021_06_01_preview/_metadata.json | 24 +- .../servicebus/v2021_06_01_preview/_patch.py | 1 + .../_service_bus_management_client.py | 73 +- .../servicebus/v2021_06_01_preview/_vendor.py | 6 +- .../v2021_06_01_preview/_version.py | 2 +- .../v2021_06_01_preview/aio/__init__.py | 7 +- .../v2021_06_01_preview/aio/_configuration.py | 50 +- .../v2021_06_01_preview/aio/_patch.py | 1 + .../aio/_service_bus_management_client.py | 64 +- .../aio/operations/__init__.py | 25 +- .../_disaster_recovery_configs_operations.py | 792 ++-- .../_migration_configs_operations.py | 475 ++- .../aio/operations/_namespaces_operations.py | 1404 +++++--- .../aio/operations/_operations.py | 84 +- .../aio/operations/_patch.py | 1 + ...private_endpoint_connections_operations.py | 384 +- .../_private_link_resources_operations.py | 64 +- .../aio/operations/_queues_operations.py | 790 ++-- .../aio/operations/_rules_operations.py | 335 +- .../operations/_subscriptions_operations.py | 335 +- .../aio/operations/_topics_operations.py | 790 ++-- .../v2021_06_01_preview/models/__init__.py | 186 +- .../v2021_06_01_preview/models/_models_py3.py | 1458 ++++---- .../v2021_06_01_preview/models/_patch.py | 1 + .../_service_bus_management_client_enums.py | 61 +- .../operations/__init__.py | 25 +- .../_disaster_recovery_configs_operations.py | 1232 ++++--- .../_migration_configs_operations.py | 718 ++-- .../operations/_namespaces_operations.py | 2095 ++++++----- .../operations/_operations.py | 114 +- .../v2021_06_01_preview/operations/_patch.py | 1 + ...private_endpoint_connections_operations.py | 555 +-- .../_private_link_resources_operations.py | 108 +- .../operations/_queues_operations.py | 1229 ++++--- .../operations/_rules_operations.py | 510 +-- .../operations/_subscriptions_operations.py | 501 +-- .../operations/_topics_operations.py | 1229 ++++--- .../mgmt/servicebus/v2021_11_01/__init__.py | 7 +- .../servicebus/v2021_11_01/_configuration.py | 51 +- .../servicebus/v2021_11_01/_metadata.json | 24 +- .../mgmt/servicebus/v2021_11_01/_patch.py | 1 + .../_service_bus_management_client.py | 73 +- .../mgmt/servicebus/v2021_11_01/_vendor.py | 6 +- .../mgmt/servicebus/v2021_11_01/_version.py | 2 +- .../servicebus/v2021_11_01/aio/__init__.py | 7 +- .../v2021_11_01/aio/_configuration.py | 50 +- .../mgmt/servicebus/v2021_11_01/aio/_patch.py | 1 + .../aio/_service_bus_management_client.py | 64 +- .../v2021_11_01/aio/operations/__init__.py | 25 +- .../_disaster_recovery_configs_operations.py | 766 ++-- .../_migration_configs_operations.py | 458 ++- .../aio/operations/_namespaces_operations.py | 1368 ++++--- .../v2021_11_01/aio/operations/_operations.py | 82 +- .../v2021_11_01/aio/operations/_patch.py | 1 + ...private_endpoint_connections_operations.py | 377 +- .../_private_link_resources_operations.py | 62 +- .../aio/operations/_queues_operations.py | 769 ++-- .../aio/operations/_rules_operations.py | 328 +- .../operations/_subscriptions_operations.py | 327 +- .../aio/operations/_topics_operations.py | 769 ++-- .../servicebus/v2021_11_01/models/__init__.py | 188 +- .../v2021_11_01/models/_models_py3.py | 1544 ++++---- .../servicebus/v2021_11_01/models/_patch.py | 1 + .../_service_bus_management_client_enums.py | 61 +- .../v2021_11_01/operations/__init__.py | 25 +- .../_disaster_recovery_configs_operations.py | 1168 +++--- .../_migration_configs_operations.py | 677 ++-- .../operations/_namespaces_operations.py | 2028 ++++++----- .../v2021_11_01/operations/_operations.py | 109 +- .../v2021_11_01/operations/_patch.py | 1 + ...private_endpoint_connections_operations.py | 532 +-- .../_private_link_resources_operations.py | 102 +- .../operations/_queues_operations.py | 1168 +++--- .../operations/_rules_operations.py | 485 ++- .../operations/_subscriptions_operations.py | 478 +-- .../operations/_topics_operations.py | 1168 +++--- .../_disaster_recovery_configs_operations.py | 796 ---- .../_migration_configs_operations.py | 553 --- .../aio/operations/_namespaces_operations.py | 1352 ------- ...private_endpoint_connections_operations.py | 415 --- .../aio/operations/_queues_operations.py | 822 ----- .../aio/operations/_rules_operations.py | 389 -- .../operations/_subscriptions_operations.py | 373 -- .../aio/operations/_topics_operations.py | 822 ----- .../v2022_01_01_preview/models/__init__.py | 171 - .../_disaster_recovery_configs_operations.py | 1212 ------- .../_migration_configs_operations.py | 795 ---- .../operations/_namespaces_operations.py | 1994 ---------- .../v2022_01_01_preview/operations/_patch.py | 19 - ...private_endpoint_connections_operations.py | 579 --- .../operations/_queues_operations.py | 1253 ------- .../operations/_rules_operations.py | 576 --- .../operations/_subscriptions_operations.py | 552 --- .../operations/_topics_operations.py | 1253 ------- .../__init__.py | 7 +- .../_configuration.py | 51 +- .../_metadata.json | 24 +- .../models => v2022_01_10_preview}/_patch.py | 1 + .../_service_bus_management_client.py | 93 +- .../_vendor.py | 6 +- .../_version.py | 2 +- .../aio/__init__.py | 7 +- .../aio/_configuration.py | 50 +- .../aio}/_patch.py | 1 + .../aio/_service_bus_management_client.py | 84 +- .../aio/operations/__init__.py | 25 +- .../_disaster_recovery_configs_operations.py | 1046 ++++++ .../_migration_configs_operations.py | 690 ++++ .../aio/operations/_namespaces_operations.py | 1808 ++++++++++ .../aio/operations/_operations.py | 86 +- .../aio/operations}/_patch.py | 1 + ...private_endpoint_connections_operations.py | 509 +++ .../_private_link_resources_operations.py | 68 +- .../aio/operations/_queues_operations.py | 1104 ++++++ .../aio/operations/_rules_operations.py | 506 +++ .../operations/_subscriptions_operations.py | 474 +++ .../aio/operations/_topics_operations.py | 1104 ++++++ .../v2022_01_10_preview/models/__init__.py | 169 + .../models/_models_py3.py | 1804 +++++----- .../models}/_patch.py | 1 + .../_service_bus_management_client_enums.py | 73 +- .../operations/__init__.py | 25 +- .../_disaster_recovery_configs_operations.py | 1420 ++++++++ .../_migration_configs_operations.py | 923 +++++ .../operations/_namespaces_operations.py | 2367 ++++++++++++ .../operations/_operations.py | 116 +- .../v2022_01_10_preview/operations/_patch.py | 20 + ...private_endpoint_connections_operations.py | 670 ++++ .../_private_link_resources_operations.py | 112 +- .../operations/_queues_operations.py | 1510 ++++++++ .../operations/_rules_operations.py | 686 ++++ .../operations/_subscriptions_operations.py | 647 ++++ .../operations/_topics_operations.py | 1510 ++++++++ .../py.typed | 0 297 files changed, 73772 insertions(+), 51458 deletions(-) create mode 100644 sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/_serialization.py delete mode 100644 sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/operations/_disaster_recovery_configs_operations.py delete mode 100644 sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/operations/_migration_configs_operations.py delete mode 100644 sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/operations/_namespaces_operations.py delete mode 100644 sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/operations/_private_endpoint_connections_operations.py delete mode 100644 sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/operations/_queues_operations.py delete mode 100644 sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/operations/_rules_operations.py delete mode 100644 sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/operations/_subscriptions_operations.py delete mode 100644 sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/operations/_topics_operations.py delete mode 100644 sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/models/__init__.py delete mode 100644 sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/operations/_disaster_recovery_configs_operations.py delete mode 100644 sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/operations/_migration_configs_operations.py delete mode 100644 sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/operations/_namespaces_operations.py delete mode 100644 sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/operations/_patch.py delete mode 100644 sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/operations/_private_endpoint_connections_operations.py delete mode 100644 sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/operations/_queues_operations.py delete mode 100644 sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/operations/_rules_operations.py delete mode 100644 sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/operations/_subscriptions_operations.py delete mode 100644 sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/operations/_topics_operations.py rename sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/{v2022_01_01_preview => v2022_01_10_preview}/__init__.py (86%) rename sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/{v2022_01_01_preview => v2022_01_10_preview}/_configuration.py (62%) rename sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/{v2022_01_01_preview => v2022_01_10_preview}/_metadata.json (75%) rename sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/{v2022_01_01_preview/models => v2022_01_10_preview}/_patch.py (99%) rename sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/{v2022_01_01_preview => v2022_01_10_preview}/_service_bus_management_client.py (66%) rename sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/{v2022_01_01_preview => v2022_01_10_preview}/_vendor.py (89%) rename sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/{v2022_01_01_preview => v2022_01_10_preview}/_version.py (95%) rename sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/{v2022_01_01_preview => v2022_01_10_preview}/aio/__init__.py (85%) rename sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/{v2022_01_01_preview => v2022_01_10_preview}/aio/_configuration.py (62%) rename sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/{v2022_01_01_preview/aio/operations => v2022_01_10_preview/aio}/_patch.py (99%) rename sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/{v2022_01_01_preview => v2022_01_10_preview}/aio/_service_bus_management_client.py (69%) rename sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/{v2022_01_01_preview => v2022_01_10_preview}/aio/operations/__init__.py (76%) create mode 100644 sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/aio/operations/_disaster_recovery_configs_operations.py create mode 100644 sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/aio/operations/_migration_configs_operations.py create mode 100644 sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/aio/operations/_namespaces_operations.py rename sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/{v2022_01_01_preview => v2022_01_10_preview}/aio/operations/_operations.py (61%) rename sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/{v2022_01_01_preview => v2022_01_10_preview/aio/operations}/_patch.py (99%) create mode 100644 sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/aio/operations/_private_endpoint_connections_operations.py rename sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/{v2022_01_01_preview => v2022_01_10_preview}/aio/operations/_private_link_resources_operations.py (63%) create mode 100644 sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/aio/operations/_queues_operations.py create mode 100644 sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/aio/operations/_rules_operations.py create mode 100644 sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/aio/operations/_subscriptions_operations.py create mode 100644 sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/aio/operations/_topics_operations.py create mode 100644 sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/models/__init__.py rename sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/{v2022_01_01_preview => v2022_01_10_preview}/models/_models_py3.py (64%) rename sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/{v2022_01_01_preview/aio => v2022_01_10_preview/models}/_patch.py (99%) rename sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/{v2022_01_01_preview => v2022_01_10_preview}/models/_service_bus_management_client_enums.py (86%) rename sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/{v2022_01_01_preview => v2022_01_10_preview}/operations/__init__.py (76%) create mode 100644 sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/operations/_disaster_recovery_configs_operations.py create mode 100644 sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/operations/_migration_configs_operations.py create mode 100644 sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/operations/_namespaces_operations.py rename sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/{v2022_01_01_preview => v2022_01_10_preview}/operations/_operations.py (58%) create mode 100644 sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/operations/_patch.py create mode 100644 sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/operations/_private_endpoint_connections_operations.py rename sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/{v2022_01_01_preview => v2022_01_10_preview}/operations/_private_link_resources_operations.py (55%) create mode 100644 sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/operations/_queues_operations.py create mode 100644 sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/operations/_rules_operations.py create mode 100644 sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/operations/_subscriptions_operations.py create mode 100644 sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/operations/_topics_operations.py rename sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/{v2022_01_01_preview => v2022_01_10_preview}/py.typed (100%) diff --git a/sdk/servicebus/azure-mgmt-servicebus/_meta.json b/sdk/servicebus/azure-mgmt-servicebus/_meta.json index 0ce811f5e2392..c3eda5d5ca8eb 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/_meta.json +++ b/sdk/servicebus/azure-mgmt-servicebus/_meta.json @@ -1,11 +1,11 @@ { - "autorest": "3.7.2", + "commit": "c9065e80b5fa2dc66a9f5285d1cb3676828017ce", + "repository_url": "https://github.com/Azure/azure-rest-api-specs", + "autorest": "3.9.2", "use": [ - "@autorest/python@5.16.0", - "@autorest/modelerfour@4.19.3" + "@autorest/python@6.2.7", + "@autorest/modelerfour@4.24.3" ], - "commit": "124789ad0942fcafded1c1dbd6d2a703b23d10c7", - "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest_command": "autorest specification/servicebus/resource-manager/readme.md --python --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --python3-only --use=@autorest/python@5.16.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", + "autorest_command": "autorest specification/servicebus/resource-manager/readme.md --generate-sample=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --use=@autorest/python@6.2.7 --use=@autorest/modelerfour@4.24.3 --version=3.9.2 --version-tolerant=False", "readme": "specification/servicebus/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/__init__.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/__init__.py index f640dac181bb7..d3e8cda5f0493 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/__init__.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/__init__.py @@ -14,3 +14,7 @@ patch_sdk() except ImportError: pass + +from ._version import VERSION + +__version__ = VERSION diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/_configuration.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/_configuration.py index a5b79adab7173..e1cc3df80b32f 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/_configuration.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/_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 ServiceBusManagementClientConfiguration(Configuration): @@ -28,19 +26,18 @@ class ServiceBusManagementClientConfiguration(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: Subscription credentials that uniquely identify a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + :param subscription_id: Subscription credentials that uniquely identify a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any ): - # type: (...) -> None if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -55,9 +52,8 @@ def __init__( def _configure( self, - **kwargs # type: Any + **kwargs: 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) diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/_serialization.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/_serialization.py new file mode 100644 index 0000000000000..2c170e28dbca2 --- /dev/null +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/_serialization.py @@ -0,0 +1,1967 @@ +# -------------------------------------------------------------------------- +# +# 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 +# pyright: reportUnnecessaryTypeIgnoreComment=false + +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 +from typing import Optional, Union, AnyStr, IO, Mapping + +try: + from urllib import quote # type: ignore +except ImportError: + from urllib.parse import quote +import xml.etree.ElementTree as ET + +import isodate # type: ignore + +from typing import Dict, Any, cast + +from azure.core.exceptions import DeserializationError, SerializationError, raise_with_traceback + +_BOM = codecs.BOM_UTF8.decode(encoding="utf-8") + + +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: Optional[Union[AnyStr, IO]], content_type: Optional[str] = None) -> 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: Optional[Union[AnyStr, IO]], headers: 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 + unicode_str = str + +_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 # type: ignore +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 +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) # type: ignore + continue + if xml_desc.get("text", False): + serialized.text = new_attr # type: ignore + continue + if isinstance(new_attr, list): + serialized.extend(new_attr) # type: ignore + 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) # type: ignore + 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) # type: ignore + else: # JSON + for k in reversed(keys): # type: ignore + unflattened = {k: new_attr} + new_attr = unflattened + + _new_attr = new_attr + _serialized = serialized + for k in keys: # type: ignore + if k not in _serialized: + _serialized.update(_new_attr) # type: ignore + _new_attr = _new_attr[k] # type: ignore + _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 = [ # type: ignore + 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): # type: ignore + # 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) # type: ignore + return result + except ValueError: + for enum_value in enum_obj: # type: ignore + 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 # type: ignore + 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 # type: ignore + 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.debug( + "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) # type: ignore + 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) # type: ignore + 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): # type: ignore + 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)) # type: ignore + + @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) # type: ignore + attr = attr + padding # type: ignore + 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) # type: ignore + 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) # type: ignore + + @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): # type: ignore + 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): # type: ignore + 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) # type: ignore + 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() # type: ignore + 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) # type: ignore + 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 diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/_service_bus_management_client.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/_service_bus_management_client.py index e19cd082a6e3a..1d378b91c6c30 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/_service_bus_management_client.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/_service_bus_management_client.py @@ -9,20 +9,17 @@ # regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING - -from msrest import Deserializer, Serializer +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 ._configuration import ServiceBusManagementClientConfiguration +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): @@ -43,9 +40,9 @@ class ServiceBusManagementClient(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: Subscription credentials that uniquely identify a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + :param subscription_id: Subscription credentials that uniquely identify a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. 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 @@ -70,12 +67,12 @@ class ServiceBusManagementClient(MultiApiClientMixin, _SDKClient): def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - api_version=None, # type: Optional[str] - base_url="https://management.azure.com", # type: str - profile=KnownProfiles.default, # type: KnownProfiles - **kwargs # type: Any + credential: "TokenCredential", + subscription_id: str, + api_version: Optional[str]=None, + base_url: str = "https://management.azure.com", + profile: KnownProfiles=KnownProfiles.default, + **kwargs: Any ): self._config = ServiceBusManagementClientConfiguration(credential, subscription_id, **kwargs) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) @@ -99,6 +96,7 @@ def models(cls, api_version=DEFAULT_API_VERSION): * 2021-06-01-preview: :mod:`v2021_06_01_preview.models` * 2021-11-01: :mod:`v2021_11_01.models` * 2022-01-01-preview: :mod:`v2022_01_01_preview.models` + * 2022-01-01-preview: :mod:`v2022_01_10_preview.models` """ if api_version == '2015-08-01': from .v2015_08_01 import models @@ -121,6 +119,9 @@ def models(cls, api_version=DEFAULT_API_VERSION): elif api_version == '2022-01-01-preview': from .v2022_01_01_preview import models return models + elif api_version == '2022-01-01-preview': + from .v2022_01_10_preview import models + return models raise ValueError("API version {} is not available".format(api_version)) @property @@ -133,6 +134,7 @@ def disaster_recovery_configs(self): * 2021-06-01-preview: :class:`DisasterRecoveryConfigsOperations` * 2021-11-01: :class:`DisasterRecoveryConfigsOperations` * 2022-01-01-preview: :class:`DisasterRecoveryConfigsOperations` + * 2022-01-01-preview: :class:`DisasterRecoveryConfigsOperations` """ api_version = self._get_api_version('disaster_recovery_configs') if api_version == '2017-04-01': @@ -147,8 +149,11 @@ def disaster_recovery_configs(self): from .v2021_11_01.operations import DisasterRecoveryConfigsOperations as OperationClass elif api_version == '2022-01-01-preview': from .v2022_01_01_preview.operations import DisasterRecoveryConfigsOperations as OperationClass + elif api_version == '2022-01-01-preview': + from .v2022_01_10_preview.operations import DisasterRecoveryConfigsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'disaster_recovery_configs'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -165,6 +170,7 @@ def event_hubs(self): from .v2018_01_01_preview.operations import EventHubsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'event_hubs'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -177,6 +183,7 @@ def migration_configs(self): * 2021-06-01-preview: :class:`MigrationConfigsOperations` * 2021-11-01: :class:`MigrationConfigsOperations` * 2022-01-01-preview: :class:`MigrationConfigsOperations` + * 2022-01-01-preview: :class:`MigrationConfigsOperations` """ api_version = self._get_api_version('migration_configs') if api_version == '2017-04-01': @@ -191,8 +198,11 @@ def migration_configs(self): from .v2021_11_01.operations import MigrationConfigsOperations as OperationClass elif api_version == '2022-01-01-preview': from .v2022_01_01_preview.operations import MigrationConfigsOperations as OperationClass + elif api_version == '2022-01-01-preview': + from .v2022_01_10_preview.operations import MigrationConfigsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'migration_configs'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -206,6 +216,7 @@ def namespaces(self): * 2021-06-01-preview: :class:`NamespacesOperations` * 2021-11-01: :class:`NamespacesOperations` * 2022-01-01-preview: :class:`NamespacesOperations` + * 2022-01-01-preview: :class:`NamespacesOperations` """ api_version = self._get_api_version('namespaces') if api_version == '2015-08-01': @@ -222,8 +233,11 @@ def namespaces(self): from .v2021_11_01.operations import NamespacesOperations as OperationClass elif api_version == '2022-01-01-preview': from .v2022_01_01_preview.operations import NamespacesOperations as OperationClass + elif api_version == '2022-01-01-preview': + from .v2022_01_10_preview.operations import NamespacesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'namespaces'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -237,6 +251,7 @@ def operations(self): * 2021-06-01-preview: :class:`Operations` * 2021-11-01: :class:`Operations` * 2022-01-01-preview: :class:`Operations` + * 2022-01-01-preview: :class:`Operations` """ api_version = self._get_api_version('operations') if api_version == '2015-08-01': @@ -253,8 +268,11 @@ def operations(self): from .v2021_11_01.operations import Operations as OperationClass elif api_version == '2022-01-01-preview': from .v2022_01_01_preview.operations import Operations as OperationClass + elif api_version == '2022-01-01-preview': + from .v2022_01_10_preview.operations import Operations as OperationClass else: raise ValueError("API version {} does not have operation group 'operations'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -271,6 +289,7 @@ def premium_messaging_regions(self): from .v2018_01_01_preview.operations import PremiumMessagingRegionsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'premium_messaging_regions'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -282,6 +301,7 @@ def private_endpoint_connections(self): * 2021-06-01-preview: :class:`PrivateEndpointConnectionsOperations` * 2021-11-01: :class:`PrivateEndpointConnectionsOperations` * 2022-01-01-preview: :class:`PrivateEndpointConnectionsOperations` + * 2022-01-01-preview: :class:`PrivateEndpointConnectionsOperations` """ api_version = self._get_api_version('private_endpoint_connections') if api_version == '2018-01-01-preview': @@ -294,8 +314,11 @@ def private_endpoint_connections(self): from .v2021_11_01.operations import PrivateEndpointConnectionsOperations as OperationClass elif api_version == '2022-01-01-preview': from .v2022_01_01_preview.operations import PrivateEndpointConnectionsOperations as OperationClass + elif api_version == '2022-01-01-preview': + from .v2022_01_10_preview.operations import PrivateEndpointConnectionsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'private_endpoint_connections'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -307,6 +330,7 @@ def private_link_resources(self): * 2021-06-01-preview: :class:`PrivateLinkResourcesOperations` * 2021-11-01: :class:`PrivateLinkResourcesOperations` * 2022-01-01-preview: :class:`PrivateLinkResourcesOperations` + * 2022-01-01-preview: :class:`PrivateLinkResourcesOperations` """ api_version = self._get_api_version('private_link_resources') if api_version == '2018-01-01-preview': @@ -319,8 +343,11 @@ def private_link_resources(self): from .v2021_11_01.operations import PrivateLinkResourcesOperations as OperationClass elif api_version == '2022-01-01-preview': from .v2022_01_01_preview.operations import PrivateLinkResourcesOperations as OperationClass + elif api_version == '2022-01-01-preview': + from .v2022_01_10_preview.operations import PrivateLinkResourcesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'private_link_resources'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -334,6 +361,7 @@ def queues(self): * 2021-06-01-preview: :class:`QueuesOperations` * 2021-11-01: :class:`QueuesOperations` * 2022-01-01-preview: :class:`QueuesOperations` + * 2022-01-01-preview: :class:`QueuesOperations` """ api_version = self._get_api_version('queues') if api_version == '2015-08-01': @@ -350,8 +378,11 @@ def queues(self): from .v2021_11_01.operations import QueuesOperations as OperationClass elif api_version == '2022-01-01-preview': from .v2022_01_01_preview.operations import QueuesOperations as OperationClass + elif api_version == '2022-01-01-preview': + from .v2022_01_10_preview.operations import QueuesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'queues'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -368,6 +399,7 @@ def regions(self): from .v2018_01_01_preview.operations import RegionsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'regions'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -380,6 +412,7 @@ def rules(self): * 2021-06-01-preview: :class:`RulesOperations` * 2021-11-01: :class:`RulesOperations` * 2022-01-01-preview: :class:`RulesOperations` + * 2022-01-01-preview: :class:`RulesOperations` """ api_version = self._get_api_version('rules') if api_version == '2017-04-01': @@ -394,8 +427,11 @@ def rules(self): from .v2021_11_01.operations import RulesOperations as OperationClass elif api_version == '2022-01-01-preview': from .v2022_01_01_preview.operations import RulesOperations as OperationClass + elif api_version == '2022-01-01-preview': + from .v2022_01_10_preview.operations import RulesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'rules'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -409,6 +445,7 @@ def subscriptions(self): * 2021-06-01-preview: :class:`SubscriptionsOperations` * 2021-11-01: :class:`SubscriptionsOperations` * 2022-01-01-preview: :class:`SubscriptionsOperations` + * 2022-01-01-preview: :class:`SubscriptionsOperations` """ api_version = self._get_api_version('subscriptions') if api_version == '2015-08-01': @@ -425,8 +462,11 @@ def subscriptions(self): from .v2021_11_01.operations import SubscriptionsOperations as OperationClass elif api_version == '2022-01-01-preview': from .v2022_01_01_preview.operations import SubscriptionsOperations as OperationClass + elif api_version == '2022-01-01-preview': + from .v2022_01_10_preview.operations import SubscriptionsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'subscriptions'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -440,6 +480,7 @@ def topics(self): * 2021-06-01-preview: :class:`TopicsOperations` * 2021-11-01: :class:`TopicsOperations` * 2022-01-01-preview: :class:`TopicsOperations` + * 2022-01-01-preview: :class:`TopicsOperations` """ api_version = self._get_api_version('topics') if api_version == '2015-08-01': @@ -456,8 +497,11 @@ def topics(self): from .v2021_11_01.operations import TopicsOperations as OperationClass elif api_version == '2022-01-01-preview': from .v2022_01_01_preview.operations import TopicsOperations as OperationClass + elif api_version == '2022-01-01-preview': + from .v2022_01_10_preview.operations import TopicsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'topics'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) def close(self): diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/aio/_configuration.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/aio/_configuration.py index d5711226f3eb3..76cccb27826c3 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/aio/_configuration.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/aio/_configuration.py @@ -26,9 +26,9 @@ class ServiceBusManagementClientConfiguration(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: Subscription credentials that uniquely identify a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + :param subscription_id: Subscription credentials that uniquely identify a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str """ @@ -36,7 +36,7 @@ def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, - **kwargs # type: Any + **kwargs: Any ) -> None: if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/aio/_service_bus_management_client.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/aio/_service_bus_management_client.py index 36bf80f71f2eb..13893320fd533 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/aio/_service_bus_management_client.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/aio/_service_bus_management_client.py @@ -11,17 +11,15 @@ from typing import Any, Optional, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.mgmt.core import AsyncARMPipelineClient from azure.profiles import KnownProfiles, ProfileDefinition from azure.profiles.multiapiclient import MultiApiClientMixin +from .._serialization import Deserializer, Serializer from ._configuration import ServiceBusManagementClientConfiguration 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): @@ -42,9 +40,9 @@ class ServiceBusManagementClient(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: Subscription credentials that uniquely identify a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + :param subscription_id: Subscription credentials that uniquely identify a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. 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 @@ -74,7 +72,7 @@ def __init__( api_version: Optional[str] = None, base_url: str = "https://management.azure.com", profile: KnownProfiles = KnownProfiles.default, - **kwargs # type: Any + **kwargs: Any ) -> None: self._config = ServiceBusManagementClientConfiguration(credential, subscription_id, **kwargs) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) @@ -98,6 +96,7 @@ def models(cls, api_version=DEFAULT_API_VERSION): * 2021-06-01-preview: :mod:`v2021_06_01_preview.models` * 2021-11-01: :mod:`v2021_11_01.models` * 2022-01-01-preview: :mod:`v2022_01_01_preview.models` + * 2022-01-01-preview: :mod:`v2022_01_10_preview.models` """ if api_version == '2015-08-01': from ..v2015_08_01 import models @@ -120,6 +119,9 @@ def models(cls, api_version=DEFAULT_API_VERSION): elif api_version == '2022-01-01-preview': from ..v2022_01_01_preview import models return models + elif api_version == '2022-01-01-preview': + from ..v2022_01_10_preview import models + return models raise ValueError("API version {} is not available".format(api_version)) @property @@ -132,6 +134,7 @@ def disaster_recovery_configs(self): * 2021-06-01-preview: :class:`DisasterRecoveryConfigsOperations` * 2021-11-01: :class:`DisasterRecoveryConfigsOperations` * 2022-01-01-preview: :class:`DisasterRecoveryConfigsOperations` + * 2022-01-01-preview: :class:`DisasterRecoveryConfigsOperations` """ api_version = self._get_api_version('disaster_recovery_configs') if api_version == '2017-04-01': @@ -146,8 +149,11 @@ def disaster_recovery_configs(self): from ..v2021_11_01.aio.operations import DisasterRecoveryConfigsOperations as OperationClass elif api_version == '2022-01-01-preview': from ..v2022_01_01_preview.aio.operations import DisasterRecoveryConfigsOperations as OperationClass + elif api_version == '2022-01-01-preview': + from ..v2022_01_10_preview.aio.operations import DisasterRecoveryConfigsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'disaster_recovery_configs'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -164,6 +170,7 @@ def event_hubs(self): from ..v2018_01_01_preview.aio.operations import EventHubsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'event_hubs'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -176,6 +183,7 @@ def migration_configs(self): * 2021-06-01-preview: :class:`MigrationConfigsOperations` * 2021-11-01: :class:`MigrationConfigsOperations` * 2022-01-01-preview: :class:`MigrationConfigsOperations` + * 2022-01-01-preview: :class:`MigrationConfigsOperations` """ api_version = self._get_api_version('migration_configs') if api_version == '2017-04-01': @@ -190,8 +198,11 @@ def migration_configs(self): from ..v2021_11_01.aio.operations import MigrationConfigsOperations as OperationClass elif api_version == '2022-01-01-preview': from ..v2022_01_01_preview.aio.operations import MigrationConfigsOperations as OperationClass + elif api_version == '2022-01-01-preview': + from ..v2022_01_10_preview.aio.operations import MigrationConfigsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'migration_configs'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -205,6 +216,7 @@ def namespaces(self): * 2021-06-01-preview: :class:`NamespacesOperations` * 2021-11-01: :class:`NamespacesOperations` * 2022-01-01-preview: :class:`NamespacesOperations` + * 2022-01-01-preview: :class:`NamespacesOperations` """ api_version = self._get_api_version('namespaces') if api_version == '2015-08-01': @@ -221,8 +233,11 @@ def namespaces(self): from ..v2021_11_01.aio.operations import NamespacesOperations as OperationClass elif api_version == '2022-01-01-preview': from ..v2022_01_01_preview.aio.operations import NamespacesOperations as OperationClass + elif api_version == '2022-01-01-preview': + from ..v2022_01_10_preview.aio.operations import NamespacesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'namespaces'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -236,6 +251,7 @@ def operations(self): * 2021-06-01-preview: :class:`Operations` * 2021-11-01: :class:`Operations` * 2022-01-01-preview: :class:`Operations` + * 2022-01-01-preview: :class:`Operations` """ api_version = self._get_api_version('operations') if api_version == '2015-08-01': @@ -252,8 +268,11 @@ def operations(self): from ..v2021_11_01.aio.operations import Operations as OperationClass elif api_version == '2022-01-01-preview': from ..v2022_01_01_preview.aio.operations import Operations as OperationClass + elif api_version == '2022-01-01-preview': + from ..v2022_01_10_preview.aio.operations import Operations as OperationClass else: raise ValueError("API version {} does not have operation group 'operations'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -270,6 +289,7 @@ def premium_messaging_regions(self): from ..v2018_01_01_preview.aio.operations import PremiumMessagingRegionsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'premium_messaging_regions'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -281,6 +301,7 @@ def private_endpoint_connections(self): * 2021-06-01-preview: :class:`PrivateEndpointConnectionsOperations` * 2021-11-01: :class:`PrivateEndpointConnectionsOperations` * 2022-01-01-preview: :class:`PrivateEndpointConnectionsOperations` + * 2022-01-01-preview: :class:`PrivateEndpointConnectionsOperations` """ api_version = self._get_api_version('private_endpoint_connections') if api_version == '2018-01-01-preview': @@ -293,8 +314,11 @@ def private_endpoint_connections(self): from ..v2021_11_01.aio.operations import PrivateEndpointConnectionsOperations as OperationClass elif api_version == '2022-01-01-preview': from ..v2022_01_01_preview.aio.operations import PrivateEndpointConnectionsOperations as OperationClass + elif api_version == '2022-01-01-preview': + from ..v2022_01_10_preview.aio.operations import PrivateEndpointConnectionsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'private_endpoint_connections'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -306,6 +330,7 @@ def private_link_resources(self): * 2021-06-01-preview: :class:`PrivateLinkResourcesOperations` * 2021-11-01: :class:`PrivateLinkResourcesOperations` * 2022-01-01-preview: :class:`PrivateLinkResourcesOperations` + * 2022-01-01-preview: :class:`PrivateLinkResourcesOperations` """ api_version = self._get_api_version('private_link_resources') if api_version == '2018-01-01-preview': @@ -318,8 +343,11 @@ def private_link_resources(self): from ..v2021_11_01.aio.operations import PrivateLinkResourcesOperations as OperationClass elif api_version == '2022-01-01-preview': from ..v2022_01_01_preview.aio.operations import PrivateLinkResourcesOperations as OperationClass + elif api_version == '2022-01-01-preview': + from ..v2022_01_10_preview.aio.operations import PrivateLinkResourcesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'private_link_resources'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -333,6 +361,7 @@ def queues(self): * 2021-06-01-preview: :class:`QueuesOperations` * 2021-11-01: :class:`QueuesOperations` * 2022-01-01-preview: :class:`QueuesOperations` + * 2022-01-01-preview: :class:`QueuesOperations` """ api_version = self._get_api_version('queues') if api_version == '2015-08-01': @@ -349,8 +378,11 @@ def queues(self): from ..v2021_11_01.aio.operations import QueuesOperations as OperationClass elif api_version == '2022-01-01-preview': from ..v2022_01_01_preview.aio.operations import QueuesOperations as OperationClass + elif api_version == '2022-01-01-preview': + from ..v2022_01_10_preview.aio.operations import QueuesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'queues'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -367,6 +399,7 @@ def regions(self): from ..v2018_01_01_preview.aio.operations import RegionsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'regions'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -379,6 +412,7 @@ def rules(self): * 2021-06-01-preview: :class:`RulesOperations` * 2021-11-01: :class:`RulesOperations` * 2022-01-01-preview: :class:`RulesOperations` + * 2022-01-01-preview: :class:`RulesOperations` """ api_version = self._get_api_version('rules') if api_version == '2017-04-01': @@ -393,8 +427,11 @@ def rules(self): from ..v2021_11_01.aio.operations import RulesOperations as OperationClass elif api_version == '2022-01-01-preview': from ..v2022_01_01_preview.aio.operations import RulesOperations as OperationClass + elif api_version == '2022-01-01-preview': + from ..v2022_01_10_preview.aio.operations import RulesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'rules'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -408,6 +445,7 @@ def subscriptions(self): * 2021-06-01-preview: :class:`SubscriptionsOperations` * 2021-11-01: :class:`SubscriptionsOperations` * 2022-01-01-preview: :class:`SubscriptionsOperations` + * 2022-01-01-preview: :class:`SubscriptionsOperations` """ api_version = self._get_api_version('subscriptions') if api_version == '2015-08-01': @@ -424,8 +462,11 @@ def subscriptions(self): from ..v2021_11_01.aio.operations import SubscriptionsOperations as OperationClass elif api_version == '2022-01-01-preview': from ..v2022_01_01_preview.aio.operations import SubscriptionsOperations as OperationClass + elif api_version == '2022-01-01-preview': + from ..v2022_01_10_preview.aio.operations import SubscriptionsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'subscriptions'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -439,6 +480,7 @@ def topics(self): * 2021-06-01-preview: :class:`TopicsOperations` * 2021-11-01: :class:`TopicsOperations` * 2022-01-01-preview: :class:`TopicsOperations` + * 2022-01-01-preview: :class:`TopicsOperations` """ api_version = self._get_api_version('topics') if api_version == '2015-08-01': @@ -455,8 +497,11 @@ def topics(self): from ..v2021_11_01.aio.operations import TopicsOperations as OperationClass elif api_version == '2022-01-01-preview': from ..v2022_01_01_preview.aio.operations import TopicsOperations as OperationClass + elif api_version == '2022-01-01-preview': + from ..v2022_01_10_preview.aio.operations import TopicsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'topics'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) async def close(self): diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/__init__.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/__init__.py index 221541a00fb6e..2e171d69863bf 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/__init__.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/__init__.py @@ -13,11 +13,14 @@ try: from ._patch import __all__ as _patch_all - from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import + from ._patch import * # pylint: disable=unused-wildcard-import except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['ServiceBusManagementClient'] + +__all__ = [ + "ServiceBusManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/_configuration.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/_configuration.py index ad9251b95ca22..5c8a1a34b850b 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/_configuration.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from ._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential @@ -25,24 +31,19 @@ class ServiceBusManagementClientConfiguration(Configuration): # pylint: disable 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: Subscription credentials that uniquely identify a Microsoft Azure - subscription. The subscription ID forms part of the URI for every service call. + subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2015-08-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(ServiceBusManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2015-08-01") # type: str + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", "2015-08-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -52,23 +53,21 @@ def __init__( 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-servicebus/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-servicebus/{}".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') + 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.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/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/_metadata.json b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/_metadata.json index fa76a032b89e1..916321324ed4a 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/_metadata.json +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_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\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ServiceBusManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"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\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ServiceBusManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"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\": [\"ServiceBusManagementClientConfiguration\"], \".._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\": [\"ServiceBusManagementClientConfiguration\"], \"..._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": "Subscription credentials that uniquely identify a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.", + "signature": "subscription_id: str,", + "description": "Subscription credentials that uniquely identify a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. 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": "Subscription credentials that uniquely identify a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.", + "description": "Subscription credentials that uniquely identify a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. Required.", "docstring_type": "str", "required": true } @@ -48,19 +48,19 @@ "service_client_specific": { "sync": { "api_version": { - "signature": "api_version=None, # type: Optional[str]", + "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=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false }, "profile": { - "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "signature": "profile: KnownProfiles=KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", "required": false @@ -103,4 +103,4 @@ "topics": "TopicsOperations", "subscriptions": "SubscriptionsOperations" } -} \ No newline at end of file +} diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/_patch.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/_patch.py index 0ad201a8c586e..f7dd32510333d 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/_patch.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/_service_bus_management_client.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/_service_bus_management_client.py index 5cf4dd237f609..e2f12ce8be3a2 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/_service_bus_management_client.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/_service_bus_management_client.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from . import models +from . import models as _models +from .._serialization import Deserializer, Serializer from ._configuration import ServiceBusManagementClientConfiguration from .operations import NamespacesOperations, Operations, QueuesOperations, SubscriptionsOperations, TopicsOperations @@ -22,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class ServiceBusManagementClient: + +class ServiceBusManagementClient: # pylint: disable=client-accepts-api-version-keyword """Azure Service Bus client. :ivar operations: Operations operations @@ -35,10 +35,10 @@ class ServiceBusManagementClient: :vartype topics: azure.mgmt.servicebus.v2015_08_01.operations.TopicsOperations :ivar subscriptions: SubscriptionsOperations operations :vartype subscriptions: azure.mgmt.servicebus.v2015_08_01.operations.SubscriptionsOperations - :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: Subscription credentials that uniquely identify a Microsoft Azure - subscription. The subscription ID forms part of the URI for every service call. + subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -56,35 +56,22 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = ServiceBusManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = ServiceBusManagementClientConfiguration( + 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)} + 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.namespaces = NamespacesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.queues = QueuesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.topics = TopicsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.subscriptions = SubscriptionsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.namespaces = NamespacesOperations(self._client, self._config, self._serialize, self._deserialize) + self.queues = QueuesOperations(self._client, self._config, self._serialize, self._deserialize) + self.topics = TopicsOperations(self._client, self._config, self._serialize, self._deserialize) + self.subscriptions = SubscriptionsOperations(self._client, self._config, self._serialize, self._deserialize) - def _send_request( - self, - request: 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 @@ -93,7 +80,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 @@ -106,15 +93,12 @@ def _send_request( request_copy.url = self._client.format_url(request_copy.url) return self._client.send_request(request_copy, **kwargs) - def close(self): - # type: () -> None + def close(self) -> None: self._client.close() - def __enter__(self): - # type: () -> ServiceBusManagementClient + def __enter__(self) -> "ServiceBusManagementClient": self._client.__enter__() return self - def __exit__(self, *exc_details): - # type: (Any) -> None + def __exit__(self, *exc_details) -> None: self._client.__exit__(*exc_details) diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/_vendor.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/_vendor.py index 138f663c53a4e..9aad73fc743e7 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/_vendor.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_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/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/_version.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/_version.py index 920456322fa12..e5754a47ce68f 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/_version.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "8.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/aio/__init__.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/aio/__init__.py index e7dd87df1f939..530b8638dfd32 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/aio/__init__.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/aio/__init__.py @@ -10,11 +10,14 @@ try: from ._patch import __all__ as _patch_all - from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import + from ._patch import * # pylint: disable=unused-wildcard-import except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['ServiceBusManagementClient'] + +__all__ = [ + "ServiceBusManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/aio/_configuration.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/aio/_configuration.py index ac7564916ab60..dc556ef9932c6 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/aio/_configuration.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from .._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential @@ -25,24 +31,19 @@ class ServiceBusManagementClientConfiguration(Configuration): # pylint: disable 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: Subscription credentials that uniquely identify a Microsoft Azure - subscription. The subscription ID forms part of the URI for every service call. + subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2015-08-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(ServiceBusManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2015-08-01") # type: str + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", "2015-08-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -52,22 +53,21 @@ def __init__( 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-servicebus/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-servicebus/{}".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/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/aio/_patch.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/aio/_patch.py index 0ad201a8c586e..f7dd32510333d 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/aio/_patch.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/aio/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/aio/_service_bus_management_client.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/aio/_service_bus_management_client.py index d825e42c93293..269c05fc1abd9 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/aio/_service_bus_management_client.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/aio/_service_bus_management_client.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from .. import models +from .. import models as _models +from ..._serialization import Deserializer, Serializer from ._configuration import ServiceBusManagementClientConfiguration from .operations import NamespacesOperations, Operations, QueuesOperations, SubscriptionsOperations, TopicsOperations @@ -22,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class ServiceBusManagementClient: + +class ServiceBusManagementClient: # pylint: disable=client-accepts-api-version-keyword """Azure Service Bus client. :ivar operations: Operations operations @@ -36,10 +36,10 @@ class ServiceBusManagementClient: :ivar subscriptions: SubscriptionsOperations operations :vartype subscriptions: azure.mgmt.servicebus.v2015_08_01.aio.operations.SubscriptionsOperations - :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: Subscription credentials that uniquely identify a Microsoft Azure - subscription. The subscription ID forms part of the URI for every service call. + subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -57,35 +57,22 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = ServiceBusManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = ServiceBusManagementClientConfiguration( + 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)} + 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.namespaces = NamespacesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.queues = QueuesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.topics = TopicsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.subscriptions = SubscriptionsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.namespaces = NamespacesOperations(self._client, self._config, self._serialize, self._deserialize) + self.queues = QueuesOperations(self._client, self._config, self._serialize, self._deserialize) + self.topics = TopicsOperations(self._client, self._config, self._serialize, self._deserialize) + self.subscriptions = SubscriptionsOperations(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 @@ -94,7 +81,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/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/aio/operations/__init__.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/aio/operations/__init__.py index b0ee9242d9859..2051d27d13ae4 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/aio/operations/__init__.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/aio/operations/__init__.py @@ -13,14 +13,15 @@ from ._subscriptions_operations import SubscriptionsOperations from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'NamespacesOperations', - 'QueuesOperations', - 'TopicsOperations', - 'SubscriptionsOperations', + "Operations", + "NamespacesOperations", + "QueuesOperations", + "TopicsOperations", + "SubscriptionsOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/aio/operations/_namespaces_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/aio/operations/_namespaces_operations.py index 60aa3a847eaa6..898ef59d24eb1 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/aio/operations/_namespaces_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/aio/operations/_namespaces_operations.py @@ -6,10 +6,19 @@ # 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, Union, cast +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod @@ -22,10 +31,30 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._namespaces_operations import build_check_name_availability_request, build_create_or_update_authorization_rule_request, build_create_or_update_request_initial, build_delete_authorization_rule_request, build_delete_request_initial, build_get_authorization_rule_request, build_get_request, build_list_authorization_rules_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_list_keys_request, build_regenerate_keys_request, build_update_request -T = TypeVar('T') +from ...operations._namespaces_operations import ( + build_check_name_availability_request, + build_create_or_update_authorization_rule_request, + build_create_or_update_request, + build_delete_authorization_rule_request, + build_delete_request, + build_get_authorization_rule_request, + build_get_request, + build_list_authorization_rules_request, + build_list_by_resource_group_request, + build_list_by_subscription_request, + build_list_keys_request, + build_regenerate_keys_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class NamespacesOperations: """ .. warning:: @@ -45,116 +74,166 @@ def __init__(self, *args, **kwargs) -> None: 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") + @overload + async def check_name_availability( + self, parameters: _models.CheckNameAvailability, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param parameters: Parameters to check availability of the given namespace name. Required. + :type parameters: ~azure.mgmt.servicebus.v2015_08_01.models.CheckNameAvailability + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckNameAvailabilityResult or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param parameters: Parameters to check availability of the given namespace name. Required. + :type 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: CheckNameAvailabilityResult or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def check_name_availability( - self, - parameters: _models.CheckNameAvailability, - **kwargs: Any + self, parameters: Union[_models.CheckNameAvailability, IO], **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Check the give namespace name availability. - :param parameters: Parameters to check availability of the given namespace name. - :type parameters: ~azure.mgmt.servicebus.v2015_08_01.models.CheckNameAvailability + :param parameters: Parameters to check availability of the given namespace name. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2015_08_01.models.CheckNameAvailability 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: CheckNameAvailabilityResult, or the result of cls(response) + :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.CheckNameAvailabilityResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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', "2015-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.CheckNameAvailabilityResult] + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CheckNameAvailabilityResult] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'CheckNameAvailability') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "CheckNameAvailability") 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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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) - deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) + deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/CheckNameAvailability"} # type: ignore - + check_name_availability.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/CheckNameAvailability" + } @distributed_trace - def list_by_subscription( - self, - **kwargs: Any - ) -> AsyncIterable[_models.NamespaceListResult]: + def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.NamespaceResource"]: """Gets all the available namespaces within the subscription, irrespective of the resource groups. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either NamespaceListResult or the result of cls(response) + :return: An iterator like instance of either NamespaceResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2015_08_01.models.NamespaceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2015_08_01.models.NamespaceResource] + :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', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.NamespaceListResult] + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + cls: ClsType[_models.NamespaceListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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'], + 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 + request.url = self._client.format_url(request.url) else: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -162,16 +241,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("NamespaceListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -181,64 +258,67 @@ 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.ServiceBus/namespaces"} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/namespaces"} @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.NamespaceListResult]: + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.NamespaceResource"]: """Gets the available namespaces within a resource group. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. 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 NamespaceListResult or the result of cls(response) + :return: An iterator like instance of either NamespaceResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2015_08_01.models.NamespaceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2015_08_01.models.NamespaceResource] + :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', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.NamespaceListResult] + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + cls: ClsType[_models.NamespaceListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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'], + 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 + request.url = self._client.format_url(request.url) else: - - 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=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -246,16 +326,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("NamespaceListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -265,52 +343,61 @@ 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.ServiceBus/namespaces"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces" + } async def _create_or_update_initial( self, resource_group_name: str, namespace_name: str, - parameters: _models.NamespaceCreateOrUpdateParameters, + parameters: Union[_models.NamespaceCreateOrUpdateParameters, IO], **kwargs: Any ) -> Optional[_models.NamespaceResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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', "2015-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.NamespaceResource]] + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.NamespaceResource]] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'NamespaceCreateOrUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "NamespaceCreateOrUpdateParameters") - request = build_create_or_update_request_initial( + request = build_create_or_update_request( resource_group_name=resource_group_name, namespace_name=namespace_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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -319,36 +406,116 @@ async def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('NamespaceResource', pipeline_response) + deserialized = self._deserialize("NamespaceResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('NamespaceResource', pipeline_response) + deserialized = self._deserialize("NamespaceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}" + } + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + namespace_name: str, + parameters: _models.NamespaceCreateOrUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.NamespaceResource]: + """Creates or updates a service namespace. Once created, this namespace's resource manifest is + immutable. This operation is idempotent. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to create a namespace resource. Required. + :type parameters: ~azure.mgmt.servicebus.v2015_08_01.models.NamespaceCreateOrUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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 NamespaceResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.servicebus.v2015_08_01.models.NamespaceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.NamespaceResource]: + """Creates or updates a service namespace. Once created, this namespace's resource manifest is + immutable. This operation is idempotent. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to create a namespace resource. Required. + :type 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 + :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 NamespaceResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.servicebus.v2015_08_01.models.NamespaceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, namespace_name: str, - parameters: _models.NamespaceCreateOrUpdateParameters, + parameters: Union[_models.NamespaceCreateOrUpdateParameters, IO], **kwargs: Any ) -> AsyncLROPoller[_models.NamespaceResource]: """Creates or updates a service namespace. Once created, this namespace's resource manifest is immutable. This operation is idempotent. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: Parameters supplied to create a namespace resource. + :param parameters: Parameters supplied to create a namespace resource. Is either a model type + or a IO type. Required. :type parameters: ~azure.mgmt.servicebus.v2015_08_01.models.NamespaceCreateOrUpdateParameters + 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 @@ -361,96 +528,89 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.servicebus.v2015_08_01.models.NamespaceResource] - :raises: ~azure.core.exceptions.HttpResponseError + :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', "2015-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.NamespaceResource] - 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] + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.NamespaceResource] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._create_or_update_initial( # type: ignore + raw_result = await self._create_or_update_initial( resource_group_name=resource_group_name, namespace_name=namespace_name, parameters=parameters, 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): - deserialized = self._deserialize('NamespaceResource', pipeline_response) + deserialized = self._deserialize("NamespaceResource", 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 + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, **kwargs: Any ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request_initial( + request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + 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 + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -460,22 +620,18 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}" + } @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete(self, resource_group_name: str, namespace_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes an existing namespace. This operation also removes all associated resources under the namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_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. @@ -487,154 +643,215 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements 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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: 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] + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, namespace_name=namespace_name, api_version=api_version, - 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 = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}" + } @distributed_trace_async - async def get( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> _models.NamespaceResource: + async def get(self, resource_group_name: str, namespace_name: str, **kwargs: Any) -> _models.NamespaceResource: """Gets a description for the specified namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: NamespaceResource, or the result of cls(response) + :return: NamespaceResource or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.NamespaceResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.NamespaceResource] + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + cls: ClsType[_models.NamespaceResource] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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) - deserialized = self._deserialize('NamespaceResource', pipeline_response) + deserialized = self._deserialize("NamespaceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}" + } - @distributed_trace_async + @overload async def update( self, resource_group_name: str, namespace_name: str, parameters: _models.NamespaceUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> Optional[_models.NamespaceResource]: """Updates a service namespace. Once created, this namespace's resource manifest is immutable. This operation is idempotent. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: Parameters supplied to update a namespace resource. + :param parameters: Parameters supplied to update a namespace resource. Required. :type parameters: ~azure.mgmt.servicebus.v2015_08_01.models.NamespaceUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: NamespaceResource or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.NamespaceResource or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> Optional[_models.NamespaceResource]: + """Updates a service namespace. Once created, this namespace's resource manifest is immutable. + This operation is idempotent. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to update a namespace resource. Required. + :type 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: NamespaceResource or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.NamespaceResource or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + namespace_name: str, + parameters: Union[_models.NamespaceUpdateParameters, IO], + **kwargs: Any + ) -> Optional[_models.NamespaceResource]: + """Updates a service namespace. Once created, this namespace's resource manifest is immutable. + This operation is idempotent. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to update a namespace resource. Is either a model type + or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2015_08_01.models.NamespaceUpdateParameters 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: NamespaceResource, or the result of cls(response) + :return: NamespaceResource or None or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.NamespaceResource or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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', "2015-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.NamespaceResource]] + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.NamespaceResource]] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'NamespaceUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "NamespaceUpdateParameters") request = build_update_request( resource_group_name=resource_group_name, @@ -643,18 +860,18 @@ async def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -663,77 +880,81 @@ async def update( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('NamespaceResource', pipeline_response) + deserialized = self._deserialize("NamespaceResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('NamespaceResource', pipeline_response) + deserialized = self._deserialize("NamespaceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore - + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}" + } @distributed_trace def list_authorization_rules( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.SharedAccessAuthorizationRuleListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> AsyncIterable["_models.SharedAccessAuthorizationRuleResource"]: """Gets the authorization rules for a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SharedAccessAuthorizationRuleListResult or the + :return: An iterator like instance of either SharedAccessAuthorizationRuleResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleResource] + :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', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SharedAccessAuthorizationRuleListResult] + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + cls: ClsType[_models.SharedAccessAuthorizationRuleListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_authorization_rules_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_authorization_rules.metadata['url'], + template_url=self.list_authorization_rules.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_authorization_rules_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -741,16 +962,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("SharedAccessAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -760,50 +979,125 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_authorization_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules"} # type: ignore + list_authorization_rules.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules" + } - @distributed_trace_async + @overload async def create_or_update_authorization_rule( self, resource_group_name: str, namespace_name: str, authorization_rule_name: str, parameters: _models.SharedAccessAuthorizationRuleCreateOrUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SharedAccessAuthorizationRuleResource: """Creates or updates an authorization rule for a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: The shared access authorization rule. + :param parameters: The shared access authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleCreateOrUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SharedAccessAuthorizationRuleResource or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SharedAccessAuthorizationRuleResource: + """Creates or updates an authorization rule for a namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Required. + :type 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: SharedAccessAuthorizationRuleResource, or the result of cls(response) + :return: SharedAccessAuthorizationRuleResource or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: Union[_models.SharedAccessAuthorizationRuleCreateOrUpdateParameters, IO], + **kwargs: Any + ) -> _models.SharedAccessAuthorizationRuleResource: + """Creates or updates an authorization rule for a namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Is either a model type or a IO type. + Required. + :type parameters: + ~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleCreateOrUpdateParameters + 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: SharedAccessAuthorizationRuleResource or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleResource + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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', "2015-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SharedAccessAuthorizationRuleResource] + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SharedAccessAuthorizationRuleResource] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'SharedAccessAuthorizationRuleCreateOrUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SharedAccessAuthorizationRuleCreateOrUpdateParameters") request = build_create_or_update_authorization_rule_request( resource_group_name=resource_group_name, @@ -813,85 +1107,83 @@ async def create_or_update_authorization_rule( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_authorization_rule.metadata['url'], + content=_content, + template_url=self.create_or_update_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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) - deserialized = self._deserialize('SharedAccessAuthorizationRuleResource', pipeline_response) + deserialized = self._deserialize("SharedAccessAuthorizationRuleResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}"} # type: ignore - + create_or_update_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}" + } @distributed_trace_async async def delete_authorization_rule( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, authorization_rule_name: str, **kwargs: Any ) -> None: """Deletes a namespace authorization rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_authorization_rule.metadata['url'], + template_url=self.delete_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -901,180 +1193,250 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat if cls: return cls(pipeline_response, None, {}) - delete_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}"} # type: ignore - + delete_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}" + } @distributed_trace_async async def get_authorization_rule( - self, - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, authorization_rule_name: str, **kwargs: Any ) -> _models.SharedAccessAuthorizationRuleResource: """Gets an authorization rule for a namespace by rule name. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SharedAccessAuthorizationRuleResource, or the result of cls(response) + :return: SharedAccessAuthorizationRuleResource or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SharedAccessAuthorizationRuleResource] + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + cls: ClsType[_models.SharedAccessAuthorizationRuleResource] = kwargs.pop("cls", None) - request = build_get_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_authorization_rule.metadata['url'], + template_url=self.get_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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) - deserialized = self._deserialize('SharedAccessAuthorizationRuleResource', pipeline_response) + deserialized = self._deserialize("SharedAccessAuthorizationRuleResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}"} # type: ignore - + get_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}" + } @distributed_trace_async async def list_keys( - self, - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, authorization_rule_name: str, **kwargs: Any ) -> _models.ResourceListKeys: """Gets the primary and secondary connection strings for the namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceListKeys, or the result of cls(response) + :return: ResourceListKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.ResourceListKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ResourceListKeys] + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + cls: ClsType[_models.ResourceListKeys] = kwargs.pop("cls", None) - request = build_list_keys_request( resource_group_name=resource_group_name, namespace_name=namespace_name, authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata['url'], + 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 + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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) - deserialized = self._deserialize('ResourceListKeys', pipeline_response) + deserialized = self._deserialize("ResourceListKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/listKeys"} # type: ignore + list_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/listKeys" + } - - @distributed_trace_async + @overload async def regenerate_keys( self, resource_group_name: str, namespace_name: str, authorization_rule_name: str, parameters: _models.RegenerateKeysParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ResourceListKeys: """Regenerates the primary or secondary connection strings for the namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate the authorization rule. + :param parameters: Parameters supplied to regenerate the authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2015_08_01.models.RegenerateKeysParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceListKeys, or the result of cls(response) + :return: ResourceListKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.ResourceListKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ResourceListKeys: + """Regenerates the primary or secondary connection strings for the namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Required. + :type 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: ResourceListKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.ResourceListKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: Union[_models.RegenerateKeysParameters, IO], + **kwargs: Any + ) -> _models.ResourceListKeys: + """Regenerates the primary or secondary connection strings for the namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2015_08_01.models.RegenerateKeysParameters 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: ResourceListKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.ResourceListKeys + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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', "2015-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ResourceListKeys] + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ResourceListKeys] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'RegenerateKeysParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RegenerateKeysParameters") request = build_regenerate_keys_request( resource_group_name=resource_group_name, @@ -1084,30 +1446,31 @@ async def regenerate_keys( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_keys.metadata['url'], + content=_content, + template_url=self.regenerate_keys.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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) - deserialized = self._deserialize('ResourceListKeys', pipeline_response) + deserialized = self._deserialize("ResourceListKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/regenerateKeys"} # type: ignore - + regenerate_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/regenerateKeys" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/aio/operations/_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/aio/operations/_operations.py index 94a1178bd32fa..bc5436afd1d83 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/aio/operations/_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/aio/operations/_operations.py @@ -6,10 +6,19 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +29,15 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._operations import build_list_request -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class Operations: """ .. warning:: @@ -42,52 +57,57 @@ def __init__(self, *args, **kwargs) -> None: 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 ServiceBus 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.servicebus.v2015_08_01.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2015_08_01.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', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_request( - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -95,16 +115,14 @@ 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) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -114,8 +132,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.ServiceBus/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.ServiceBus/operations"} diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/aio/operations/_patch.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/aio/operations/_patch.py index 0ad201a8c586e..f7dd32510333d 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/aio/operations/_patch.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/aio/operations/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/aio/operations/_queues_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/aio/operations/_queues_operations.py index 2d121cca8b227..3de162332b952 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/aio/operations/_queues_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/aio/operations/_queues_operations.py @@ -6,10 +6,19 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,28 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._queues_operations import build_create_or_update_authorization_rule_request, build_create_or_update_request, build_delete_authorization_rule_request, build_delete_request, build_get_authorization_rule_request, build_get_request, build_list_all_request, build_list_authorization_rules_request, build_list_keys_request, build_post_authorization_rule_request, build_regenerate_keys_request -T = TypeVar('T') +from ...operations._queues_operations import ( + build_create_or_update_authorization_rule_request, + build_create_or_update_request, + build_delete_authorization_rule_request, + build_delete_request, + build_get_authorization_rule_request, + build_get_request, + build_list_all_request, + build_list_authorization_rules_request, + build_list_keys_request, + build_post_authorization_rule_request, + build_regenerate_keys_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class QueuesOperations: """ .. warning:: @@ -43,64 +70,66 @@ def __init__(self, *args, **kwargs) -> None: 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_all( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.QueueListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> AsyncIterable["_models.QueueResource"]: """Gets the queues within a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either QueueListResult or the result of cls(response) + :return: An iterator like instance of either QueueResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2015_08_01.models.QueueListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2015_08_01.models.QueueResource] + :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', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.QueueListResult] + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + cls: ClsType[_models.QueueListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_all_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_all.metadata['url'], + template_url=self.list_all.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_all_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -108,16 +137,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("QueueListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -127,49 +154,122 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_all.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues"} # type: ignore + list_all.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues" + } - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, namespace_name: str, queue_name: str, parameters: _models.QueueCreateOrUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.QueueResource: """Creates or updates a Service Bus queue. This operation is idempotent. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param parameters: Parameters supplied to create or update a queue resource. + :param parameters: Parameters supplied to create or update a queue resource. Required. :type parameters: ~azure.mgmt.servicebus.v2015_08_01.models.QueueCreateOrUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: QueueResource or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.QueueResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.QueueResource: + """Creates or updates a Service Bus queue. This operation is idempotent. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param parameters: Parameters supplied to create or update a queue resource. Required. + :type 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: QueueResource, or the result of cls(response) + :return: QueueResource or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.QueueResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + parameters: Union[_models.QueueCreateOrUpdateParameters, IO], + **kwargs: Any + ) -> _models.QueueResource: + """Creates or updates a Service Bus queue. This operation is idempotent. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param parameters: Parameters supplied to create or update a queue resource. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2015_08_01.models.QueueCreateOrUpdateParameters 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: QueueResource or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.QueueResource + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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', "2015-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.QueueResource] + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.QueueResource] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'QueueCreateOrUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "QueueCreateOrUpdateParameters") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -179,85 +279,83 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - 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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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) - deserialized = self._deserialize('QueueResource', pipeline_response) + deserialized = self._deserialize("QueueResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}"} # type: ignore - + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}" + } @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - queue_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, queue_name: str, **kwargs: Any ) -> None: """Deletes a queue from the specified namespace in a resource group. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, queue_name=queue_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -267,139 +365,139 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}"} # type: ignore - + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}" + } @distributed_trace_async async def get( - self, - resource_group_name: str, - namespace_name: str, - queue_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, queue_name: str, **kwargs: Any ) -> _models.QueueResource: """Returns a description for the specified queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: QueueResource, or the result of cls(response) + :return: QueueResource or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.QueueResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.QueueResource] + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + cls: ClsType[_models.QueueResource] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, queue_name=queue_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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) - deserialized = self._deserialize('QueueResource', pipeline_response) + deserialized = self._deserialize("QueueResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}" + } @distributed_trace def list_authorization_rules( - self, - resource_group_name: str, - namespace_name: str, - queue_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.SharedAccessAuthorizationRuleListResult]: + self, resource_group_name: str, namespace_name: str, queue_name: str, **kwargs: Any + ) -> AsyncIterable["_models.SharedAccessAuthorizationRuleResource"]: """Gets all authorization rules for a queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SharedAccessAuthorizationRuleListResult or the + :return: An iterator like instance of either SharedAccessAuthorizationRuleResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleResource] + :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', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SharedAccessAuthorizationRuleListResult] + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + cls: ClsType[_models.SharedAccessAuthorizationRuleListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_authorization_rules_request( resource_group_name=resource_group_name, namespace_name=namespace_name, queue_name=queue_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_authorization_rules.metadata['url'], + template_url=self.list_authorization_rules.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_authorization_rules_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - queue_name=queue_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -407,16 +505,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("SharedAccessAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -426,13 +522,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_authorization_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules"} # type: ignore + list_authorization_rules.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules" + } - @distributed_trace_async + @overload async def create_or_update_authorization_rule( self, resource_group_name: str, @@ -440,39 +536,120 @@ async def create_or_update_authorization_rule( queue_name: str, authorization_rule_name: str, parameters: _models.SharedAccessAuthorizationRuleCreateOrUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SharedAccessAuthorizationRuleResource: + """Creates an authorization rule for a queue. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Required. + :type parameters: + ~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleCreateOrUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SharedAccessAuthorizationRuleResource or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SharedAccessAuthorizationRuleResource: + """Creates an authorization rule for a queue. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Required. + :type 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: SharedAccessAuthorizationRuleResource or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: Union[_models.SharedAccessAuthorizationRuleCreateOrUpdateParameters, IO], **kwargs: Any ) -> _models.SharedAccessAuthorizationRuleResource: """Creates an authorization rule for a queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: The shared access authorization rule. + :param parameters: The shared access authorization rule. Is either a model type or a IO type. + Required. :type parameters: ~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleCreateOrUpdateParameters + 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: SharedAccessAuthorizationRuleResource, or the result of cls(response) + :return: SharedAccessAuthorizationRuleResource or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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', "2015-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SharedAccessAuthorizationRuleResource] + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SharedAccessAuthorizationRuleResource] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'SharedAccessAuthorizationRuleCreateOrUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SharedAccessAuthorizationRuleCreateOrUpdateParameters") request = build_create_or_update_authorization_rule_request( resource_group_name=resource_group_name, @@ -483,33 +660,34 @@ async def create_or_update_authorization_rule( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_authorization_rule.metadata['url'], + content=_content, + template_url=self.create_or_update_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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) - deserialized = self._deserialize('SharedAccessAuthorizationRuleResource', pipeline_response) + deserialized = self._deserialize("SharedAccessAuthorizationRuleResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}"} # type: ignore - + create_or_update_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}" + } @distributed_trace_async async def post_authorization_rule( @@ -522,31 +700,33 @@ async def post_authorization_rule( ) -> _models.SharedAccessAuthorizationRuleResource: """Gets an authorization rule for a queue by rule name. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SharedAccessAuthorizationRuleResource, or the result of cls(response) + :return: SharedAccessAuthorizationRuleResource or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SharedAccessAuthorizationRuleResource] + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + cls: ClsType[_models.SharedAccessAuthorizationRuleResource] = kwargs.pop("cls", None) - request = build_post_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -554,33 +734,33 @@ async def post_authorization_rule( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.post_authorization_rule.metadata['url'], + template_url=self.post_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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) - deserialized = self._deserialize('SharedAccessAuthorizationRuleResource', pipeline_response) + deserialized = self._deserialize("SharedAccessAuthorizationRuleResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - post_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}"} # type: ignore - + post_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}" + } @distributed_trace_async async def delete_authorization_rule( # pylint: disable=inconsistent-return-statements @@ -593,31 +773,33 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat ) -> None: """Deletes a queue authorization rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -625,18 +807,17 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_authorization_rule.metadata['url'], + template_url=self.delete_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -646,8 +827,9 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat if cls: return cls(pipeline_response, None, {}) - delete_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}"} # type: ignore - + delete_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}" + } @distributed_trace_async async def get_authorization_rule( @@ -660,31 +842,33 @@ async def get_authorization_rule( ) -> _models.SharedAccessAuthorizationRuleResource: """Gets an authorization rule for a queue by rule name. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SharedAccessAuthorizationRuleResource, or the result of cls(response) + :return: SharedAccessAuthorizationRuleResource or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SharedAccessAuthorizationRuleResource] + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + cls: ClsType[_models.SharedAccessAuthorizationRuleResource] = kwargs.pop("cls", None) - request = build_get_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -692,33 +876,33 @@ async def get_authorization_rule( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_authorization_rule.metadata['url'], + template_url=self.get_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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) - deserialized = self._deserialize('SharedAccessAuthorizationRuleResource', pipeline_response) + deserialized = self._deserialize("SharedAccessAuthorizationRuleResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}"} # type: ignore - + get_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}" + } @distributed_trace_async async def list_keys( @@ -731,31 +915,33 @@ async def list_keys( ) -> _models.ResourceListKeys: """Primary and secondary connection strings to the queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceListKeys, or the result of cls(response) + :return: ResourceListKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.ResourceListKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ResourceListKeys] + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + cls: ClsType[_models.ResourceListKeys] = kwargs.pop("cls", None) - request = build_list_keys_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -763,35 +949,35 @@ async def list_keys( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata['url'], + 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 + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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) - deserialized = self._deserialize('ResourceListKeys', pipeline_response) + deserialized = self._deserialize("ResourceListKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/ListKeys"} # type: ignore - + list_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/ListKeys" + } - @distributed_trace_async + @overload async def regenerate_keys( self, resource_group_name: str, @@ -799,38 +985,117 @@ async def regenerate_keys( queue_name: str, authorization_rule_name: str, parameters: _models.RegenerateKeysParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ResourceListKeys: """Regenerates the primary or secondary connection strings to the queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate the authorization rule. + :param parameters: Parameters supplied to regenerate the authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2015_08_01.models.RegenerateKeysParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceListKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.ResourceListKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ResourceListKeys: + """Regenerates the primary or secondary connection strings to the queue. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Required. + :type 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: ResourceListKeys, or the result of cls(response) + :return: ResourceListKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.ResourceListKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: Union[_models.RegenerateKeysParameters, IO], + **kwargs: Any + ) -> _models.ResourceListKeys: + """Regenerates the primary or secondary connection strings to the queue. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2015_08_01.models.RegenerateKeysParameters 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: ResourceListKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.ResourceListKeys + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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', "2015-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ResourceListKeys] + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ResourceListKeys] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'RegenerateKeysParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RegenerateKeysParameters") request = build_regenerate_keys_request( resource_group_name=resource_group_name, @@ -841,30 +1106,31 @@ async def regenerate_keys( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_keys.metadata['url'], + content=_content, + template_url=self.regenerate_keys.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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) - deserialized = self._deserialize('ResourceListKeys', pipeline_response) + deserialized = self._deserialize("ResourceListKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/regenerateKeys"} # type: ignore - + regenerate_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/regenerateKeys" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/aio/operations/_subscriptions_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/aio/operations/_subscriptions_operations.py index 466a3e2d1a2dd..41c93fe4a695c 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/aio/operations/_subscriptions_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/aio/operations/_subscriptions_operations.py @@ -6,10 +6,19 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,21 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._subscriptions_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_all_request -T = TypeVar('T') +from ...operations._subscriptions_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_all_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class SubscriptionsOperations: """ .. warning:: @@ -43,70 +63,70 @@ def __init__(self, *args, **kwargs) -> None: 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_all( - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.SubscriptionListResult]: + self, resource_group_name: str, namespace_name: str, topic_name: str, **kwargs: Any + ) -> AsyncIterable["_models.SubscriptionResource"]: """List all the subscriptions under a specified topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SubscriptionListResult or the result of + :return: An iterator like instance of either SubscriptionResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2015_08_01.models.SubscriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2015_08_01.models.SubscriptionResource] + :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', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SubscriptionListResult] + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + cls: ClsType[_models.SubscriptionListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_all_request( resource_group_name=resource_group_name, namespace_name=namespace_name, topic_name=topic_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_all.metadata['url'], + template_url=self.list_all.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_all_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - topic_name=topic_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -114,16 +134,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("SubscriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -133,13 +151,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_all.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions"} # type: ignore + list_all.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions" + } - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, @@ -147,39 +165,119 @@ async def create_or_update( topic_name: str, subscription_name: str, parameters: _models.SubscriptionCreateOrUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SubscriptionResource: """Creates a topic subscription. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str - :param parameters: Parameters supplied to create a subscription resource. + :param parameters: Parameters supplied to create a subscription resource. Required. :type parameters: ~azure.mgmt.servicebus.v2015_08_01.models.SubscriptionCreateOrUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SubscriptionResource or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.SubscriptionResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SubscriptionResource: + """Creates a topic subscription. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param parameters: Parameters supplied to create a subscription resource. Required. + :type 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: SubscriptionResource, or the result of cls(response) + :return: SubscriptionResource or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.SubscriptionResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + parameters: Union[_models.SubscriptionCreateOrUpdateParameters, IO], + **kwargs: Any + ) -> _models.SubscriptionResource: + """Creates a topic subscription. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param parameters: Parameters supplied to create a subscription resource. Is either a model + type or a IO type. Required. + :type parameters: + ~azure.mgmt.servicebus.v2015_08_01.models.SubscriptionCreateOrUpdateParameters 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: SubscriptionResource or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.SubscriptionResource + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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', "2015-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SubscriptionResource] + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SubscriptionResource] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'SubscriptionCreateOrUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SubscriptionCreateOrUpdateParameters") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -190,70 +288,68 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - 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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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) - deserialized = self._deserialize('SubscriptionResource', pipeline_response) + deserialized = self._deserialize("SubscriptionResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}"} # type: ignore - + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}" + } @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - subscription_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, topic_name: str, subscription_name: str, **kwargs: Any ) -> None: """Deletes a subscription from the specified topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -261,18 +357,17 @@ async def delete( # pylint: disable=inconsistent-return-statements subscription_name=subscription_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -282,45 +377,43 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}"} # type: ignore - + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}" + } @distributed_trace_async async def get( - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - subscription_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, topic_name: str, subscription_name: str, **kwargs: Any ) -> _models.SubscriptionResource: """Returns a subscription description for the specified topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SubscriptionResource, or the result of cls(response) + :return: SubscriptionResource or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.SubscriptionResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SubscriptionResource] + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + cls: ClsType[_models.SubscriptionResource] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -328,30 +421,30 @@ async def get( subscription_name=subscription_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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) - deserialized = self._deserialize('SubscriptionResource', pipeline_response) + deserialized = self._deserialize("SubscriptionResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/aio/operations/_topics_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/aio/operations/_topics_operations.py index 13690278409c3..0fd19c9cbe317 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/aio/operations/_topics_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/aio/operations/_topics_operations.py @@ -6,10 +6,19 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,28 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._topics_operations import build_create_or_update_authorization_rule_request, build_create_or_update_request, build_delete_authorization_rule_request, build_delete_request, build_get_authorization_rule_request, build_get_request, build_list_all_request, build_list_authorization_rules_request, build_list_keys_request, build_post_authorization_rule_request, build_regenerate_keys_request -T = TypeVar('T') +from ...operations._topics_operations import ( + build_create_or_update_authorization_rule_request, + build_create_or_update_request, + build_delete_authorization_rule_request, + build_delete_request, + build_get_authorization_rule_request, + build_get_request, + build_list_all_request, + build_list_authorization_rules_request, + build_list_keys_request, + build_post_authorization_rule_request, + build_regenerate_keys_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class TopicsOperations: """ .. warning:: @@ -43,64 +70,66 @@ def __init__(self, *args, **kwargs) -> None: 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_all( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.TopicListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> AsyncIterable["_models.TopicResource"]: """Gets all the topics in a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TopicListResult or the result of cls(response) + :return: An iterator like instance of either TopicResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2015_08_01.models.TopicListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2015_08_01.models.TopicResource] + :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', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.TopicListResult] + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + cls: ClsType[_models.TopicListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_all_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_all.metadata['url'], + template_url=self.list_all.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_all_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -108,16 +137,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("TopicListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -127,49 +154,122 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_all.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics"} # type: ignore + list_all.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics" + } - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, namespace_name: str, topic_name: str, parameters: _models.TopicCreateOrUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.TopicResource: """Creates a topic in the specified namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param parameters: Parameters supplied to create a topic resource. + :param parameters: Parameters supplied to create a topic resource. Required. :type parameters: ~azure.mgmt.servicebus.v2015_08_01.models.TopicCreateOrUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TopicResource or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.TopicResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TopicResource: + """Creates a topic in the specified namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param parameters: Parameters supplied to create a topic resource. Required. + :type 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: TopicResource, or the result of cls(response) + :return: TopicResource or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.TopicResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + parameters: Union[_models.TopicCreateOrUpdateParameters, IO], + **kwargs: Any + ) -> _models.TopicResource: + """Creates a topic in the specified namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param parameters: Parameters supplied to create a topic resource. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2015_08_01.models.TopicCreateOrUpdateParameters 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: TopicResource or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.TopicResource + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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', "2015-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.TopicResource] + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.TopicResource] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'TopicCreateOrUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TopicCreateOrUpdateParameters") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -179,85 +279,83 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - 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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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) - deserialized = self._deserialize('TopicResource', pipeline_response) + deserialized = self._deserialize("TopicResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}"} # type: ignore - + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}" + } @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, topic_name: str, **kwargs: Any ) -> None: """Deletes a topic from the specified namespace and resource group. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, topic_name=topic_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -267,139 +365,139 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}"} # type: ignore - + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}" + } @distributed_trace_async async def get( - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, topic_name: str, **kwargs: Any ) -> _models.TopicResource: """Returns a description for the specified topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TopicResource, or the result of cls(response) + :return: TopicResource or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.TopicResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.TopicResource] + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + cls: ClsType[_models.TopicResource] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, topic_name=topic_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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) - deserialized = self._deserialize('TopicResource', pipeline_response) + deserialized = self._deserialize("TopicResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}" + } @distributed_trace def list_authorization_rules( - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.SharedAccessAuthorizationRuleListResult]: + self, resource_group_name: str, namespace_name: str, topic_name: str, **kwargs: Any + ) -> AsyncIterable["_models.SharedAccessAuthorizationRuleResource"]: """Gets authorization rules for a topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SharedAccessAuthorizationRuleListResult or the + :return: An iterator like instance of either SharedAccessAuthorizationRuleResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleResource] + :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', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SharedAccessAuthorizationRuleListResult] + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + cls: ClsType[_models.SharedAccessAuthorizationRuleListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_authorization_rules_request( resource_group_name=resource_group_name, namespace_name=namespace_name, topic_name=topic_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_authorization_rules.metadata['url'], + template_url=self.list_authorization_rules.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_authorization_rules_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - topic_name=topic_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -407,16 +505,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("SharedAccessAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -426,13 +522,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_authorization_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules"} # type: ignore + list_authorization_rules.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules" + } - @distributed_trace_async + @overload async def create_or_update_authorization_rule( self, resource_group_name: str, @@ -440,39 +536,120 @@ async def create_or_update_authorization_rule( topic_name: str, authorization_rule_name: str, parameters: _models.SharedAccessAuthorizationRuleCreateOrUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SharedAccessAuthorizationRuleResource: + """Creates an authorization rule for the specified topic. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Required. + :type parameters: + ~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleCreateOrUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SharedAccessAuthorizationRuleResource or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SharedAccessAuthorizationRuleResource: + """Creates an authorization rule for the specified topic. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Required. + :type 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: SharedAccessAuthorizationRuleResource or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: Union[_models.SharedAccessAuthorizationRuleCreateOrUpdateParameters, IO], **kwargs: Any ) -> _models.SharedAccessAuthorizationRuleResource: """Creates an authorization rule for the specified topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: The shared access authorization rule. + :param parameters: The shared access authorization rule. Is either a model type or a IO type. + Required. :type parameters: ~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleCreateOrUpdateParameters + 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: SharedAccessAuthorizationRuleResource, or the result of cls(response) + :return: SharedAccessAuthorizationRuleResource or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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', "2015-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SharedAccessAuthorizationRuleResource] + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SharedAccessAuthorizationRuleResource] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'SharedAccessAuthorizationRuleCreateOrUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SharedAccessAuthorizationRuleCreateOrUpdateParameters") request = build_create_or_update_authorization_rule_request( resource_group_name=resource_group_name, @@ -483,33 +660,34 @@ async def create_or_update_authorization_rule( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_authorization_rule.metadata['url'], + content=_content, + template_url=self.create_or_update_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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) - deserialized = self._deserialize('SharedAccessAuthorizationRuleResource', pipeline_response) + deserialized = self._deserialize("SharedAccessAuthorizationRuleResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}"} # type: ignore - + create_or_update_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}" + } @distributed_trace_async async def post_authorization_rule( @@ -522,31 +700,33 @@ async def post_authorization_rule( ) -> _models.SharedAccessAuthorizationRuleResource: """Returns the specified authorization rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SharedAccessAuthorizationRuleResource, or the result of cls(response) + :return: SharedAccessAuthorizationRuleResource or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SharedAccessAuthorizationRuleResource] + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + cls: ClsType[_models.SharedAccessAuthorizationRuleResource] = kwargs.pop("cls", None) - request = build_post_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -554,33 +734,33 @@ async def post_authorization_rule( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.post_authorization_rule.metadata['url'], + template_url=self.post_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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) - deserialized = self._deserialize('SharedAccessAuthorizationRuleResource', pipeline_response) + deserialized = self._deserialize("SharedAccessAuthorizationRuleResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - post_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}"} # type: ignore - + post_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}" + } @distributed_trace_async async def get_authorization_rule( @@ -593,31 +773,33 @@ async def get_authorization_rule( ) -> _models.SharedAccessAuthorizationRuleResource: """Returns the specified authorization rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SharedAccessAuthorizationRuleResource, or the result of cls(response) + :return: SharedAccessAuthorizationRuleResource or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SharedAccessAuthorizationRuleResource] + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + cls: ClsType[_models.SharedAccessAuthorizationRuleResource] = kwargs.pop("cls", None) - request = build_get_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -625,33 +807,33 @@ async def get_authorization_rule( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_authorization_rule.metadata['url'], + template_url=self.get_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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) - deserialized = self._deserialize('SharedAccessAuthorizationRuleResource', pipeline_response) + deserialized = self._deserialize("SharedAccessAuthorizationRuleResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}"} # type: ignore - + get_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}" + } @distributed_trace_async async def delete_authorization_rule( # pylint: disable=inconsistent-return-statements @@ -664,31 +846,33 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat ) -> None: """Deletes a topic authorization rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -696,18 +880,17 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_authorization_rule.metadata['url'], + template_url=self.delete_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -717,8 +900,9 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat if cls: return cls(pipeline_response, None, {}) - delete_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}"} # type: ignore - + delete_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}" + } @distributed_trace_async async def list_keys( @@ -731,31 +915,33 @@ async def list_keys( ) -> _models.ResourceListKeys: """Gets the primary and secondary connection strings for the topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceListKeys, or the result of cls(response) + :return: ResourceListKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.ResourceListKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ResourceListKeys] + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + cls: ClsType[_models.ResourceListKeys] = kwargs.pop("cls", None) - request = build_list_keys_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -763,35 +949,35 @@ async def list_keys( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata['url'], + 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 + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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) - deserialized = self._deserialize('ResourceListKeys', pipeline_response) + deserialized = self._deserialize("ResourceListKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/ListKeys"} # type: ignore - + list_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/ListKeys" + } - @distributed_trace_async + @overload async def regenerate_keys( self, resource_group_name: str, @@ -799,38 +985,117 @@ async def regenerate_keys( topic_name: str, authorization_rule_name: str, parameters: _models.RegenerateKeysParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ResourceListKeys: """Regenerates primary or secondary connection strings for the topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate the authorization rule. + :param parameters: Parameters supplied to regenerate the authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2015_08_01.models.RegenerateKeysParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceListKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.ResourceListKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ResourceListKeys: + """Regenerates primary or secondary connection strings for the topic. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Required. + :type 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: ResourceListKeys, or the result of cls(response) + :return: ResourceListKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.ResourceListKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: Union[_models.RegenerateKeysParameters, IO], + **kwargs: Any + ) -> _models.ResourceListKeys: + """Regenerates primary or secondary connection strings for the topic. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2015_08_01.models.RegenerateKeysParameters 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: ResourceListKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.ResourceListKeys + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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', "2015-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ResourceListKeys] + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ResourceListKeys] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'RegenerateKeysParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RegenerateKeysParameters") request = build_regenerate_keys_request( resource_group_name=resource_group_name, @@ -841,30 +1106,31 @@ async def regenerate_keys( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_keys.metadata['url'], + content=_content, + template_url=self.regenerate_keys.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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) - deserialized = self._deserialize('ResourceListKeys', pipeline_response) + deserialized = self._deserialize("ResourceListKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/regenerateKeys"} # type: ignore - + regenerate_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/regenerateKeys" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/models/__init__.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/models/__init__.py index c44dce4e28b6c..1992ae248260c 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/models/__init__.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/models/__init__.py @@ -34,56 +34,54 @@ from ._models_py3 import TopicResource from ._models_py3 import TrackedResource - -from ._service_bus_management_client_enums import ( - AccessRights, - EntityAvailabilityStatus, - EntityStatus, - NamespaceState, - Policykey, - SkuName, - SkuTier, - UnavailableReason, -) +from ._service_bus_management_client_enums import AccessRights +from ._service_bus_management_client_enums import EntityAvailabilityStatus +from ._service_bus_management_client_enums import EntityStatus +from ._service_bus_management_client_enums import NamespaceState +from ._service_bus_management_client_enums import Policykey +from ._service_bus_management_client_enums import SkuName +from ._service_bus_management_client_enums import SkuTier +from ._service_bus_management_client_enums import UnavailableReason from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'CheckNameAvailability', - 'CheckNameAvailabilityResult', - 'MessageCountDetails', - 'NamespaceCreateOrUpdateParameters', - 'NamespaceListResult', - 'NamespaceResource', - 'NamespaceUpdateParameters', - 'Operation', - 'OperationDisplay', - 'OperationListResult', - 'QueueCreateOrUpdateParameters', - 'QueueListResult', - 'QueueResource', - 'RegenerateKeysParameters', - 'Resource', - 'ResourceListKeys', - 'SharedAccessAuthorizationRuleCreateOrUpdateParameters', - 'SharedAccessAuthorizationRuleListResult', - 'SharedAccessAuthorizationRuleResource', - 'Sku', - 'SubscriptionCreateOrUpdateParameters', - 'SubscriptionListResult', - 'SubscriptionResource', - 'TopicCreateOrUpdateParameters', - 'TopicListResult', - 'TopicResource', - 'TrackedResource', - 'AccessRights', - 'EntityAvailabilityStatus', - 'EntityStatus', - 'NamespaceState', - 'Policykey', - 'SkuName', - 'SkuTier', - 'UnavailableReason', + "CheckNameAvailability", + "CheckNameAvailabilityResult", + "MessageCountDetails", + "NamespaceCreateOrUpdateParameters", + "NamespaceListResult", + "NamespaceResource", + "NamespaceUpdateParameters", + "Operation", + "OperationDisplay", + "OperationListResult", + "QueueCreateOrUpdateParameters", + "QueueListResult", + "QueueResource", + "RegenerateKeysParameters", + "Resource", + "ResourceListKeys", + "SharedAccessAuthorizationRuleCreateOrUpdateParameters", + "SharedAccessAuthorizationRuleListResult", + "SharedAccessAuthorizationRuleResource", + "Sku", + "SubscriptionCreateOrUpdateParameters", + "SubscriptionListResult", + "SubscriptionResource", + "TopicCreateOrUpdateParameters", + "TopicListResult", + "TopicResource", + "TrackedResource", + "AccessRights", + "EntityAvailabilityStatus", + "EntityStatus", + "NamespaceState", + "Policykey", + "SkuName", + "SkuTier", + "UnavailableReason", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/models/_models_py3.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/models/_models_py3.py index c418f4487af8a..02f6c10354a3d 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/models/_models_py3.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_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. @@ -8,49 +9,44 @@ from typing import Dict, List, Optional, TYPE_CHECKING, Union -import msrest.serialization +from ... import _serialization if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - import __init__ as _models + from .. import models as _models -class CheckNameAvailability(msrest.serialization.Model): +class CheckNameAvailability(_serialization.Model): """Description of a Check Name availability request properties. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The Name to check the namespace name availability and The namespace name - can contain only letters, numbers, and hyphens. The namespace must start with a letter, and it - must end with a letter or number. + :ivar name: The Name to check the namespace name availability and The namespace name can + contain only letters, numbers, and hyphens. The namespace must start with a letter, and it must + end with a letter or number. 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 to check the namespace name availability and The namespace - name can contain only letters, numbers, and hyphens. The namespace must start with a letter, - and it must end with a letter or number. + :keyword name: The Name to check the namespace name availability and The namespace name can + contain only letters, numbers, and hyphens. The namespace must start with a letter, and it must + end with a letter or number. Required. :paramtype name: str """ - super(CheckNameAvailability, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class CheckNameAvailabilityResult(msrest.serialization.Model): +class CheckNameAvailabilityResult(_serialization.Model): """Description of a Check Name availability request properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -59,7 +55,7 @@ class CheckNameAvailabilityResult(msrest.serialization.Model): available; otherwise, false. :vartype name_available: bool :ivar reason: The reason for unavailability of a namespace. Known values are: "None", - "InvalidName", "SubscriptionIsDisabled", "NameInUse", "NameInLockdown", + "InvalidName", "SubscriptionIsDisabled", "NameInUse", "NameInLockdown", and "TooManyNamespaceInCurrentSubscription". :vartype reason: str or ~azure.mgmt.servicebus.v2015_08_01.models.UnavailableReason :ivar message: The detailed info regarding the reason associated with the namespace. @@ -67,13 +63,13 @@ class CheckNameAvailabilityResult(msrest.serialization.Model): """ _validation = { - 'message': {'readonly': True}, + "message": {"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__( @@ -88,57 +84,53 @@ def __init__( available; otherwise, false. :paramtype name_available: bool :keyword reason: The reason for unavailability of a namespace. Known values are: "None", - "InvalidName", "SubscriptionIsDisabled", "NameInUse", "NameInLockdown", + "InvalidName", "SubscriptionIsDisabled", "NameInUse", "NameInLockdown", and "TooManyNamespaceInCurrentSubscription". :paramtype reason: str or ~azure.mgmt.servicebus.v2015_08_01.models.UnavailableReason """ - super(CheckNameAvailabilityResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.name_available = name_available self.reason = reason self.message = None -class MessageCountDetails(msrest.serialization.Model): +class MessageCountDetails(_serialization.Model): """Message Count Details. Variables are only populated by the server, and will be ignored when sending a request. :ivar active_message_count: Number of active messages in the queue, topic, or subscription. - :vartype active_message_count: long + :vartype active_message_count: int :ivar dead_letter_message_count: Number of messages that are dead lettered. - :vartype dead_letter_message_count: long + :vartype dead_letter_message_count: int :ivar scheduled_message_count: Number of scheduled messages. - :vartype scheduled_message_count: long + :vartype scheduled_message_count: int :ivar transfer_dead_letter_message_count: Number of messages transferred into dead letters. - :vartype transfer_dead_letter_message_count: long + :vartype transfer_dead_letter_message_count: int :ivar transfer_message_count: Number of messages transferred to another queue, topic, or subscription. - :vartype transfer_message_count: long + :vartype transfer_message_count: int """ _validation = { - 'active_message_count': {'readonly': True}, - 'dead_letter_message_count': {'readonly': True}, - 'scheduled_message_count': {'readonly': True}, - 'transfer_dead_letter_message_count': {'readonly': True}, - 'transfer_message_count': {'readonly': True}, + "active_message_count": {"readonly": True}, + "dead_letter_message_count": {"readonly": True}, + "scheduled_message_count": {"readonly": True}, + "transfer_dead_letter_message_count": {"readonly": True}, + "transfer_message_count": {"readonly": True}, } _attribute_map = { - 'active_message_count': {'key': 'activeMessageCount', 'type': 'long'}, - 'dead_letter_message_count': {'key': 'deadLetterMessageCount', 'type': 'long'}, - 'scheduled_message_count': {'key': 'scheduledMessageCount', 'type': 'long'}, - 'transfer_dead_letter_message_count': {'key': 'transferDeadLetterMessageCount', 'type': 'long'}, - 'transfer_message_count': {'key': 'transferMessageCount', 'type': 'long'}, + "active_message_count": {"key": "activeMessageCount", "type": "int"}, + "dead_letter_message_count": {"key": "deadLetterMessageCount", "type": "int"}, + "scheduled_message_count": {"key": "scheduledMessageCount", "type": "int"}, + "transfer_dead_letter_message_count": {"key": "transferDeadLetterMessageCount", "type": "int"}, + "transfer_message_count": {"key": "transferMessageCount", "type": "int"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(MessageCountDetails, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.active_message_count = None self.dead_letter_message_count = None self.scheduled_message_count = None @@ -146,24 +138,24 @@ def __init__( self.transfer_message_count = None -class NamespaceCreateOrUpdateParameters(msrest.serialization.Model): +class NamespaceCreateOrUpdateParameters(_serialization.Model): """Parameters supplied to the Create Or Update Namespace operation. 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 location: Required. Namespace location. + :ivar location: Namespace location. Required. :vartype location: str :ivar sku: SKU of the namespace. :vartype sku: ~azure.mgmt.servicebus.v2015_08_01.models.Sku - :ivar tags: A set of tags. Namespace tags. + :ivar tags: Namespace tags. :vartype tags: dict[str, str] :ivar provisioning_state: Provisioning state of the namespace. :vartype provisioning_state: str :ivar status: State of the namespace. Known values are: "Unknown", "Creating", "Created", "Activating", "Enabling", "Active", "Disabling", "Disabled", "SoftDeleting", "SoftDeleted", - "Removing", "Removed", "Failed". + "Removing", "Removed", and "Failed". :vartype status: str or ~azure.mgmt.servicebus.v2015_08_01.models.NamespaceState :ivar created_at: The time the namespace was created. :vartype created_at: ~datetime.datetime @@ -178,24 +170,24 @@ class NamespaceCreateOrUpdateParameters(msrest.serialization.Model): """ _validation = { - 'location': {'required': True}, - 'provisioning_state': {'readonly': True}, - 'created_at': {'readonly': True}, - 'updated_at': {'readonly': True}, - 'service_bus_endpoint': {'readonly': True}, + "location": {"required": True}, + "provisioning_state": {"readonly": True}, + "created_at": {"readonly": True}, + "updated_at": {"readonly": True}, + "service_bus_endpoint": {"readonly": True}, } _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'created_at': {'key': 'properties.createdAt', 'type': 'iso-8601'}, - 'updated_at': {'key': 'properties.updatedAt', 'type': 'iso-8601'}, - 'service_bus_endpoint': {'key': 'properties.serviceBusEndpoint', 'type': 'str'}, - 'create_acs_namespace': {'key': 'properties.createACSNamespace', 'type': 'bool'}, - 'enabled': {'key': 'properties.enabled', 'type': 'bool'}, + "location": {"key": "location", "type": "str"}, + "sku": {"key": "sku", "type": "Sku"}, + "tags": {"key": "tags", "type": "{str}"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "status": {"key": "properties.status", "type": "str"}, + "created_at": {"key": "properties.createdAt", "type": "iso-8601"}, + "updated_at": {"key": "properties.updatedAt", "type": "iso-8601"}, + "service_bus_endpoint": {"key": "properties.serviceBusEndpoint", "type": "str"}, + "create_acs_namespace": {"key": "properties.createACSNamespace", "type": "bool"}, + "enabled": {"key": "properties.enabled", "type": "bool"}, } def __init__( @@ -210,22 +202,22 @@ def __init__( **kwargs ): """ - :keyword location: Required. Namespace location. + :keyword location: Namespace location. Required. :paramtype location: str :keyword sku: SKU of the namespace. :paramtype sku: ~azure.mgmt.servicebus.v2015_08_01.models.Sku - :keyword tags: A set of tags. Namespace tags. + :keyword tags: Namespace tags. :paramtype tags: dict[str, str] :keyword status: State of the namespace. Known values are: "Unknown", "Creating", "Created", "Activating", "Enabling", "Active", "Disabling", "Disabled", "SoftDeleting", "SoftDeleted", - "Removing", "Removed", "Failed". + "Removing", "Removed", and "Failed". :paramtype status: str or ~azure.mgmt.servicebus.v2015_08_01.models.NamespaceState :keyword create_acs_namespace: Indicates whether to create an ACS namespace. :paramtype create_acs_namespace: bool :keyword enabled: Specifies whether this instance is enabled. :paramtype enabled: bool """ - super(NamespaceCreateOrUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.sku = sku self.tags = tags @@ -238,7 +230,7 @@ def __init__( self.enabled = enabled -class NamespaceListResult(msrest.serialization.Model): +class NamespaceListResult(_serialization.Model): """The response of the List Namespace operation. :ivar value: Result of the List Namespace operation. @@ -249,16 +241,12 @@ class NamespaceListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[NamespaceResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[NamespaceResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["_models.NamespaceResource"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.NamespaceResource"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Result of the List Namespace operation. @@ -267,12 +255,12 @@ def __init__( list of Namespaces. :paramtype next_link: str """ - super(NamespaceListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class Resource(msrest.serialization.Model): +class Resource(_serialization.Model): """The Resource definition for other than namespace. Variables are only populated by the server, and will be ignored when sending a request. @@ -288,29 +276,24 @@ class Resource(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - *, - location: Optional[str] = None, - **kwargs - ): + def __init__(self, *, location: Optional[str] = None, **kwargs): """ :keyword location: Resource location. :paramtype location: str """ - super(Resource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.location = location @@ -330,42 +313,36 @@ class TrackedResource(Resource): :vartype location: str :ivar type: Resource type. :vartype type: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, } - def __init__( - self, - *, - location: Optional[str] = None, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, **kwargs): """ :keyword location: Resource location. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] """ - super(TrackedResource, self).__init__(location=location, **kwargs) + super().__init__(location=location, **kwargs) self.tags = tags -class NamespaceResource(TrackedResource): +class NamespaceResource(TrackedResource): # pylint: disable=too-many-instance-attributes """Description of a namespace resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -378,7 +355,7 @@ class NamespaceResource(TrackedResource): :vartype location: str :ivar type: Resource type. :vartype type: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar sku: SKU of the namespace. :vartype sku: ~azure.mgmt.servicebus.v2015_08_01.models.Sku @@ -386,7 +363,7 @@ class NamespaceResource(TrackedResource): :vartype provisioning_state: str :ivar status: State of the namespace. Known values are: "Unknown", "Creating", "Created", "Activating", "Enabling", "Active", "Disabling", "Disabled", "SoftDeleting", "SoftDeleted", - "Removing", "Removed", "Failed". + "Removing", "Removed", and "Failed". :vartype status: str or ~azure.mgmt.servicebus.v2015_08_01.models.NamespaceState :ivar created_at: The time the namespace was created. :vartype created_at: ~datetime.datetime @@ -401,29 +378,29 @@ class NamespaceResource(TrackedResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'created_at': {'readonly': True}, - 'updated_at': {'readonly': True}, - 'service_bus_endpoint': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "created_at": {"readonly": True}, + "updated_at": {"readonly": True}, + "service_bus_endpoint": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'created_at': {'key': 'properties.createdAt', 'type': 'iso-8601'}, - 'updated_at': {'key': 'properties.updatedAt', 'type': 'iso-8601'}, - 'service_bus_endpoint': {'key': 'properties.serviceBusEndpoint', 'type': 'str'}, - 'create_acs_namespace': {'key': 'properties.createACSNamespace', 'type': 'bool'}, - 'enabled': {'key': 'properties.enabled', 'type': 'bool'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "sku": {"key": "sku", "type": "Sku"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "status": {"key": "properties.status", "type": "str"}, + "created_at": {"key": "properties.createdAt", "type": "iso-8601"}, + "updated_at": {"key": "properties.updatedAt", "type": "iso-8601"}, + "service_bus_endpoint": {"key": "properties.serviceBusEndpoint", "type": "str"}, + "create_acs_namespace": {"key": "properties.createACSNamespace", "type": "bool"}, + "enabled": {"key": "properties.enabled", "type": "bool"}, } def __init__( @@ -440,20 +417,20 @@ def __init__( """ :keyword location: Resource location. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword sku: SKU of the namespace. :paramtype sku: ~azure.mgmt.servicebus.v2015_08_01.models.Sku :keyword status: State of the namespace. Known values are: "Unknown", "Creating", "Created", "Activating", "Enabling", "Active", "Disabling", "Disabled", "SoftDeleting", "SoftDeleted", - "Removing", "Removed", "Failed". + "Removing", "Removed", and "Failed". :paramtype status: str or ~azure.mgmt.servicebus.v2015_08_01.models.NamespaceState :keyword create_acs_namespace: Indicates whether to create an ACS namespace. :paramtype create_acs_namespace: bool :keyword enabled: Specifies whether this instance is enabled. :paramtype enabled: bool """ - super(NamespaceResource, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.sku = sku self.provisioning_state = None self.status = status @@ -464,39 +441,33 @@ def __init__( self.enabled = enabled -class NamespaceUpdateParameters(msrest.serialization.Model): +class NamespaceUpdateParameters(_serialization.Model): """Parameters supplied to the Patch Namespace operation. - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar sku: The sku of the created namespace. :vartype sku: ~azure.mgmt.servicebus.v2015_08_01.models.Sku """ _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, + "tags": {"key": "tags", "type": "{str}"}, + "sku": {"key": "sku", "type": "Sku"}, } - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - sku: Optional["_models.Sku"] = None, - **kwargs - ): + def __init__(self, *, tags: Optional[Dict[str, str]] = None, sku: Optional["_models.Sku"] = None, **kwargs): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword sku: The sku of the created namespace. :paramtype sku: ~azure.mgmt.servicebus.v2015_08_01.models.Sku """ - super(NamespaceUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.sku = sku -class Operation(msrest.serialization.Model): +class Operation(_serialization.Model): """A ServiceBus REST API operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -508,30 +479,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["_models.OperationDisplay"] = None, - **kwargs - ): + def __init__(self, *, display: Optional["_models.OperationDisplay"] = None, **kwargs): """ :keyword display: The object that represents the operation. :paramtype display: ~azure.mgmt.servicebus.v2015_08_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. @@ -545,30 +511,26 @@ 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 OperationListResult(msrest.serialization.Model): +class OperationListResult(_serialization.Model): """Result of the request to list ServiceBus 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. @@ -581,27 +543,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 QueueCreateOrUpdateParameters(msrest.serialization.Model): +class QueueCreateOrUpdateParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes """Parameters supplied to the Create Or Update Queue operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -610,7 +568,7 @@ class QueueCreateOrUpdateParameters(msrest.serialization.Model): :ivar name: Queue name. :vartype name: str - :ivar location: Required. location of the resource. + :ivar location: location of the resource. Required. :vartype location: str :ivar lock_duration: The duration of a peek-lock; that is, the amount of time that the message is locked for other receivers. The maximum value for LockDuration is 5 minutes; the default @@ -623,7 +581,7 @@ class QueueCreateOrUpdateParameters(msrest.serialization.Model): deleted. The minimum duration is 5 minutes. :vartype auto_delete_on_idle: str :ivar entity_availability_status: Entity availability status for the queue. Known values are: - "Available", "Limited", "Renaming", "Restoring", "Unknown". + "Available", "Limited", "Renaming", "Restoring", and "Unknown". :vartype entity_availability_status: str or ~azure.mgmt.servicebus.v2015_08_01.models.EntityAvailabilityStatus :ivar created_at: The exact time the message was created. @@ -655,9 +613,9 @@ class QueueCreateOrUpdateParameters(msrest.serialization.Model): :vartype max_delivery_count: int :ivar max_size_in_megabytes: The maximum size of the queue in megabytes, which is the size of memory allocated for the queue. - :vartype max_size_in_megabytes: long + :vartype max_size_in_megabytes: int :ivar message_count: The number of messages in the queue. - :vartype message_count: long + :vartype message_count: int :ivar count_details: Message Count Details. :vartype count_details: ~azure.mgmt.servicebus.v2015_08_01.models.MessageCountDetails :ivar requires_duplicate_detection: A value indicating if this queue requires duplicate @@ -667,10 +625,10 @@ class QueueCreateOrUpdateParameters(msrest.serialization.Model): sessions. :vartype requires_session: bool :ivar size_in_bytes: The size of the queue, in bytes. - :vartype size_in_bytes: long + :vartype size_in_bytes: int :ivar status: Enumerates the possible values for the status of a messaging entity. Known values are: "Active", "Creating", "Deleting", "Disabled", "ReceiveDisabled", "Renaming", "Restoring", - "SendDisabled", "Unknown". + "SendDisabled", and "Unknown". :vartype status: str or ~azure.mgmt.servicebus.v2015_08_01.models.EntityStatus :ivar support_ordering: A value that indicates whether the queue supports ordering. :vartype support_ordering: bool @@ -679,43 +637,46 @@ class QueueCreateOrUpdateParameters(msrest.serialization.Model): """ _validation = { - 'location': {'required': True}, - 'accessed_at': {'readonly': True}, - 'created_at': {'readonly': True}, - 'message_count': {'readonly': True}, - 'count_details': {'readonly': True}, - 'size_in_bytes': {'readonly': True}, - 'updated_at': {'readonly': True}, + "location": {"required": True}, + "accessed_at": {"readonly": True}, + "created_at": {"readonly": True}, + "message_count": {"readonly": True}, + "count_details": {"readonly": True}, + "size_in_bytes": {"readonly": True}, + "updated_at": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'lock_duration': {'key': 'properties.lockDuration', 'type': 'str'}, - 'accessed_at': {'key': 'properties.accessedAt', 'type': 'iso-8601'}, - 'auto_delete_on_idle': {'key': 'properties.autoDeleteOnIdle', 'type': 'str'}, - 'entity_availability_status': {'key': 'properties.entityAvailabilityStatus', 'type': 'str'}, - 'created_at': {'key': 'properties.createdAt', 'type': 'iso-8601'}, - 'default_message_time_to_live': {'key': 'properties.defaultMessageTimeToLive', 'type': 'str'}, - 'duplicate_detection_history_time_window': {'key': 'properties.duplicateDetectionHistoryTimeWindow', 'type': 'str'}, - 'enable_batched_operations': {'key': 'properties.enableBatchedOperations', 'type': 'bool'}, - 'dead_lettering_on_message_expiration': {'key': 'properties.deadLetteringOnMessageExpiration', 'type': 'bool'}, - 'enable_express': {'key': 'properties.enableExpress', 'type': 'bool'}, - 'enable_partitioning': {'key': 'properties.enablePartitioning', 'type': 'bool'}, - 'is_anonymous_accessible': {'key': 'properties.isAnonymousAccessible', 'type': 'bool'}, - 'max_delivery_count': {'key': 'properties.maxDeliveryCount', 'type': 'int'}, - 'max_size_in_megabytes': {'key': 'properties.maxSizeInMegabytes', 'type': 'long'}, - 'message_count': {'key': 'properties.messageCount', 'type': 'long'}, - 'count_details': {'key': 'properties.countDetails', 'type': 'MessageCountDetails'}, - 'requires_duplicate_detection': {'key': 'properties.requiresDuplicateDetection', 'type': 'bool'}, - 'requires_session': {'key': 'properties.requiresSession', 'type': 'bool'}, - 'size_in_bytes': {'key': 'properties.sizeInBytes', 'type': 'long'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'support_ordering': {'key': 'properties.supportOrdering', 'type': 'bool'}, - 'updated_at': {'key': 'properties.updatedAt', 'type': 'iso-8601'}, + "name": {"key": "name", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "lock_duration": {"key": "properties.lockDuration", "type": "str"}, + "accessed_at": {"key": "properties.accessedAt", "type": "iso-8601"}, + "auto_delete_on_idle": {"key": "properties.autoDeleteOnIdle", "type": "str"}, + "entity_availability_status": {"key": "properties.entityAvailabilityStatus", "type": "str"}, + "created_at": {"key": "properties.createdAt", "type": "iso-8601"}, + "default_message_time_to_live": {"key": "properties.defaultMessageTimeToLive", "type": "str"}, + "duplicate_detection_history_time_window": { + "key": "properties.duplicateDetectionHistoryTimeWindow", + "type": "str", + }, + "enable_batched_operations": {"key": "properties.enableBatchedOperations", "type": "bool"}, + "dead_lettering_on_message_expiration": {"key": "properties.deadLetteringOnMessageExpiration", "type": "bool"}, + "enable_express": {"key": "properties.enableExpress", "type": "bool"}, + "enable_partitioning": {"key": "properties.enablePartitioning", "type": "bool"}, + "is_anonymous_accessible": {"key": "properties.isAnonymousAccessible", "type": "bool"}, + "max_delivery_count": {"key": "properties.maxDeliveryCount", "type": "int"}, + "max_size_in_megabytes": {"key": "properties.maxSizeInMegabytes", "type": "int"}, + "message_count": {"key": "properties.messageCount", "type": "int"}, + "count_details": {"key": "properties.countDetails", "type": "MessageCountDetails"}, + "requires_duplicate_detection": {"key": "properties.requiresDuplicateDetection", "type": "bool"}, + "requires_session": {"key": "properties.requiresSession", "type": "bool"}, + "size_in_bytes": {"key": "properties.sizeInBytes", "type": "int"}, + "status": {"key": "properties.status", "type": "str"}, + "support_ordering": {"key": "properties.supportOrdering", "type": "bool"}, + "updated_at": {"key": "properties.updatedAt", "type": "iso-8601"}, } - def __init__( + def __init__( # pylint: disable=too-many-locals self, *, location: str, @@ -741,7 +702,7 @@ def __init__( """ :keyword name: Queue name. :paramtype name: str - :keyword location: Required. location of the resource. + :keyword location: location of the resource. Required. :paramtype location: str :keyword lock_duration: The duration of a peek-lock; that is, the amount of time that the message is locked for other receivers. The maximum value for LockDuration is 5 minutes; the @@ -751,7 +712,7 @@ def __init__( deleted. The minimum duration is 5 minutes. :paramtype auto_delete_on_idle: str :keyword entity_availability_status: Entity availability status for the queue. Known values - are: "Available", "Limited", "Renaming", "Restoring", "Unknown". + are: "Available", "Limited", "Renaming", "Restoring", and "Unknown". :paramtype entity_availability_status: str or ~azure.mgmt.servicebus.v2015_08_01.models.EntityAvailabilityStatus :keyword default_message_time_to_live: The default message time to live value. This is the @@ -781,7 +742,7 @@ def __init__( :paramtype max_delivery_count: int :keyword max_size_in_megabytes: The maximum size of the queue in megabytes, which is the size of memory allocated for the queue. - :paramtype max_size_in_megabytes: long + :paramtype max_size_in_megabytes: int :keyword requires_duplicate_detection: A value indicating if this queue requires duplicate detection. :paramtype requires_duplicate_detection: bool @@ -790,12 +751,12 @@ def __init__( :paramtype requires_session: bool :keyword status: Enumerates the possible values for the status of a messaging entity. Known values are: "Active", "Creating", "Deleting", "Disabled", "ReceiveDisabled", "Renaming", - "Restoring", "SendDisabled", "Unknown". + "Restoring", "SendDisabled", and "Unknown". :paramtype status: str or ~azure.mgmt.servicebus.v2015_08_01.models.EntityStatus :keyword support_ordering: A value that indicates whether the queue supports ordering. :paramtype support_ordering: bool """ - super(QueueCreateOrUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.location = location self.lock_duration = lock_duration @@ -822,7 +783,7 @@ def __init__( self.updated_at = None -class QueueListResult(msrest.serialization.Model): +class QueueListResult(_serialization.Model): """The response to the List Queues operation. :ivar value: Result of the List Queues operation. @@ -833,16 +794,12 @@ class QueueListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[QueueResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[QueueResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["_models.QueueResource"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.QueueResource"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Result of the List Queues operation. @@ -851,12 +808,12 @@ def __init__( list of queues. :paramtype next_link: str """ - super(QueueListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class QueueResource(Resource): +class QueueResource(Resource): # pylint: disable=too-many-instance-attributes """Description of queue Resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -880,7 +837,7 @@ class QueueResource(Resource): deleted. The minimum duration is 5 minutes. :vartype auto_delete_on_idle: str :ivar entity_availability_status: Entity availability status for the queue. Known values are: - "Available", "Limited", "Renaming", "Restoring", "Unknown". + "Available", "Limited", "Renaming", "Restoring", and "Unknown". :vartype entity_availability_status: str or ~azure.mgmt.servicebus.v2015_08_01.models.EntityAvailabilityStatus :ivar created_at: The exact time the message was created. @@ -912,9 +869,9 @@ class QueueResource(Resource): :vartype max_delivery_count: int :ivar max_size_in_megabytes: The maximum size of the queue in megabytes, which is the size of memory allocated for the queue. - :vartype max_size_in_megabytes: long + :vartype max_size_in_megabytes: int :ivar message_count: The number of messages in the queue. - :vartype message_count: long + :vartype message_count: int :ivar count_details: Message Count Details. :vartype count_details: ~azure.mgmt.servicebus.v2015_08_01.models.MessageCountDetails :ivar requires_duplicate_detection: A value indicating if this queue requires duplicate @@ -924,10 +881,10 @@ class QueueResource(Resource): sessions. :vartype requires_session: bool :ivar size_in_bytes: The size of the queue, in bytes. - :vartype size_in_bytes: long + :vartype size_in_bytes: int :ivar status: Enumerates the possible values for the status of a messaging entity. Known values are: "Active", "Creating", "Deleting", "Disabled", "ReceiveDisabled", "Renaming", "Restoring", - "SendDisabled", "Unknown". + "SendDisabled", and "Unknown". :vartype status: str or ~azure.mgmt.servicebus.v2015_08_01.models.EntityStatus :ivar support_ordering: A value that indicates whether the queue supports ordering. :vartype support_ordering: bool @@ -936,47 +893,50 @@ class QueueResource(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'accessed_at': {'readonly': True}, - 'created_at': {'readonly': True}, - 'message_count': {'readonly': True}, - 'count_details': {'readonly': True}, - 'size_in_bytes': {'readonly': True}, - 'updated_at': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "accessed_at": {"readonly": True}, + "created_at": {"readonly": True}, + "message_count": {"readonly": True}, + "count_details": {"readonly": True}, + "size_in_bytes": {"readonly": True}, + "updated_at": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'lock_duration': {'key': 'properties.lockDuration', 'type': 'str'}, - 'accessed_at': {'key': 'properties.accessedAt', 'type': 'iso-8601'}, - 'auto_delete_on_idle': {'key': 'properties.autoDeleteOnIdle', 'type': 'str'}, - 'entity_availability_status': {'key': 'properties.entityAvailabilityStatus', 'type': 'str'}, - 'created_at': {'key': 'properties.createdAt', 'type': 'iso-8601'}, - 'default_message_time_to_live': {'key': 'properties.defaultMessageTimeToLive', 'type': 'str'}, - 'duplicate_detection_history_time_window': {'key': 'properties.duplicateDetectionHistoryTimeWindow', 'type': 'str'}, - 'enable_batched_operations': {'key': 'properties.enableBatchedOperations', 'type': 'bool'}, - 'dead_lettering_on_message_expiration': {'key': 'properties.deadLetteringOnMessageExpiration', 'type': 'bool'}, - 'enable_express': {'key': 'properties.enableExpress', 'type': 'bool'}, - 'enable_partitioning': {'key': 'properties.enablePartitioning', 'type': 'bool'}, - 'is_anonymous_accessible': {'key': 'properties.isAnonymousAccessible', 'type': 'bool'}, - 'max_delivery_count': {'key': 'properties.maxDeliveryCount', 'type': 'int'}, - 'max_size_in_megabytes': {'key': 'properties.maxSizeInMegabytes', 'type': 'long'}, - 'message_count': {'key': 'properties.messageCount', 'type': 'long'}, - 'count_details': {'key': 'properties.countDetails', 'type': 'MessageCountDetails'}, - 'requires_duplicate_detection': {'key': 'properties.requiresDuplicateDetection', 'type': 'bool'}, - 'requires_session': {'key': 'properties.requiresSession', 'type': 'bool'}, - 'size_in_bytes': {'key': 'properties.sizeInBytes', 'type': 'long'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'support_ordering': {'key': 'properties.supportOrdering', 'type': 'bool'}, - 'updated_at': {'key': 'properties.updatedAt', 'type': 'iso-8601'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "lock_duration": {"key": "properties.lockDuration", "type": "str"}, + "accessed_at": {"key": "properties.accessedAt", "type": "iso-8601"}, + "auto_delete_on_idle": {"key": "properties.autoDeleteOnIdle", "type": "str"}, + "entity_availability_status": {"key": "properties.entityAvailabilityStatus", "type": "str"}, + "created_at": {"key": "properties.createdAt", "type": "iso-8601"}, + "default_message_time_to_live": {"key": "properties.defaultMessageTimeToLive", "type": "str"}, + "duplicate_detection_history_time_window": { + "key": "properties.duplicateDetectionHistoryTimeWindow", + "type": "str", + }, + "enable_batched_operations": {"key": "properties.enableBatchedOperations", "type": "bool"}, + "dead_lettering_on_message_expiration": {"key": "properties.deadLetteringOnMessageExpiration", "type": "bool"}, + "enable_express": {"key": "properties.enableExpress", "type": "bool"}, + "enable_partitioning": {"key": "properties.enablePartitioning", "type": "bool"}, + "is_anonymous_accessible": {"key": "properties.isAnonymousAccessible", "type": "bool"}, + "max_delivery_count": {"key": "properties.maxDeliveryCount", "type": "int"}, + "max_size_in_megabytes": {"key": "properties.maxSizeInMegabytes", "type": "int"}, + "message_count": {"key": "properties.messageCount", "type": "int"}, + "count_details": {"key": "properties.countDetails", "type": "MessageCountDetails"}, + "requires_duplicate_detection": {"key": "properties.requiresDuplicateDetection", "type": "bool"}, + "requires_session": {"key": "properties.requiresSession", "type": "bool"}, + "size_in_bytes": {"key": "properties.sizeInBytes", "type": "int"}, + "status": {"key": "properties.status", "type": "str"}, + "support_ordering": {"key": "properties.supportOrdering", "type": "bool"}, + "updated_at": {"key": "properties.updatedAt", "type": "iso-8601"}, } - def __init__( + def __init__( # pylint: disable=too-many-locals self, *, location: Optional[str] = None, @@ -1009,7 +969,7 @@ def __init__( deleted. The minimum duration is 5 minutes. :paramtype auto_delete_on_idle: str :keyword entity_availability_status: Entity availability status for the queue. Known values - are: "Available", "Limited", "Renaming", "Restoring", "Unknown". + are: "Available", "Limited", "Renaming", "Restoring", and "Unknown". :paramtype entity_availability_status: str or ~azure.mgmt.servicebus.v2015_08_01.models.EntityAvailabilityStatus :keyword default_message_time_to_live: The default message time to live value. This is the @@ -1039,7 +999,7 @@ def __init__( :paramtype max_delivery_count: int :keyword max_size_in_megabytes: The maximum size of the queue in megabytes, which is the size of memory allocated for the queue. - :paramtype max_size_in_megabytes: long + :paramtype max_size_in_megabytes: int :keyword requires_duplicate_detection: A value indicating if this queue requires duplicate detection. :paramtype requires_duplicate_detection: bool @@ -1048,12 +1008,12 @@ def __init__( :paramtype requires_session: bool :keyword status: Enumerates the possible values for the status of a messaging entity. Known values are: "Active", "Creating", "Deleting", "Disabled", "ReceiveDisabled", "Renaming", - "Restoring", "SendDisabled", "Unknown". + "Restoring", "SendDisabled", and "Unknown". :paramtype status: str or ~azure.mgmt.servicebus.v2015_08_01.models.EntityStatus :keyword support_ordering: A value that indicates whether the queue supports ordering. :paramtype support_ordering: bool """ - super(QueueResource, self).__init__(location=location, **kwargs) + super().__init__(location=location, **kwargs) self.lock_duration = lock_duration self.accessed_at = None self.auto_delete_on_idle = auto_delete_on_idle @@ -1078,34 +1038,29 @@ def __init__( self.updated_at = None -class RegenerateKeysParameters(msrest.serialization.Model): +class RegenerateKeysParameters(_serialization.Model): """Parameters supplied to the Regenerate Authorization Rule operation. - :ivar policykey: Key that needs to be regenerated. Known values are: "PrimaryKey", + :ivar policykey: Key that needs to be regenerated. Known values are: "PrimaryKey" and "SecondaryKey". :vartype policykey: str or ~azure.mgmt.servicebus.v2015_08_01.models.Policykey """ _attribute_map = { - 'policykey': {'key': 'Policykey', 'type': 'str'}, + "policykey": {"key": "Policykey", "type": "str"}, } - def __init__( - self, - *, - policykey: Optional[Union[str, "_models.Policykey"]] = None, - **kwargs - ): + def __init__(self, *, policykey: Optional[Union[str, "_models.Policykey"]] = None, **kwargs): """ - :keyword policykey: Key that needs to be regenerated. Known values are: "PrimaryKey", + :keyword policykey: Key that needs to be regenerated. Known values are: "PrimaryKey" and "SecondaryKey". :paramtype policykey: str or ~azure.mgmt.servicebus.v2015_08_01.models.Policykey """ - super(RegenerateKeysParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.policykey = policykey -class ResourceListKeys(msrest.serialization.Model): +class ResourceListKeys(_serialization.Model): """Namespace/ServiceBus Connection String. :ivar primary_connection_string: Primary connection string of the created namespace @@ -1125,11 +1080,11 @@ class ResourceListKeys(msrest.serialization.Model): """ _attribute_map = { - 'primary_connection_string': {'key': 'primaryConnectionString', 'type': 'str'}, - 'secondary_connection_string': {'key': 'secondaryConnectionString', 'type': 'str'}, - 'primary_key': {'key': 'primaryKey', 'type': 'str'}, - 'secondary_key': {'key': 'secondaryKey', 'type': 'str'}, - 'key_name': {'key': 'keyName', 'type': 'str'}, + "primary_connection_string": {"key": "primaryConnectionString", "type": "str"}, + "secondary_connection_string": {"key": "secondaryConnectionString", "type": "str"}, + "primary_key": {"key": "primaryKey", "type": "str"}, + "secondary_key": {"key": "secondaryKey", "type": "str"}, + "key_name": {"key": "keyName", "type": "str"}, } def __init__( @@ -1158,7 +1113,7 @@ def __init__( :keyword key_name: A string that describes the authorization rule. :paramtype key_name: str """ - super(ResourceListKeys, self).__init__(**kwargs) + super().__init__(**kwargs) self.primary_connection_string = primary_connection_string self.secondary_connection_string = secondary_connection_string self.primary_key = primary_key @@ -1166,7 +1121,7 @@ def __init__( self.key_name = key_name -class SharedAccessAuthorizationRuleCreateOrUpdateParameters(msrest.serialization.Model): +class SharedAccessAuthorizationRuleCreateOrUpdateParameters(_serialization.Model): """Parameters supplied to the Create Or Update Authorization Rules operation. :ivar location: data center location. @@ -1178,9 +1133,9 @@ class SharedAccessAuthorizationRuleCreateOrUpdateParameters(msrest.serialization """ _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'rights': {'key': 'properties.rights', 'type': '[str]'}, + "location": {"key": "location", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "rights": {"key": "properties.rights", "type": "[str]"}, } def __init__( @@ -1199,13 +1154,13 @@ def __init__( :keyword rights: The rights associated with the rule. :paramtype rights: list[str or ~azure.mgmt.servicebus.v2015_08_01.models.AccessRights] """ - super(SharedAccessAuthorizationRuleCreateOrUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.name = name self.rights = rights -class SharedAccessAuthorizationRuleListResult(msrest.serialization.Model): +class SharedAccessAuthorizationRuleListResult(_serialization.Model): """The response to the List Namespace operation. :ivar value: Result of the List Authorization Rules operation. @@ -1217,8 +1172,8 @@ class SharedAccessAuthorizationRuleListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[SharedAccessAuthorizationRuleResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SharedAccessAuthorizationRuleResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( @@ -1236,7 +1191,7 @@ def __init__( list of Authorization Rules. :paramtype next_link: str """ - super(SharedAccessAuthorizationRuleListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link @@ -1259,17 +1214,17 @@ class SharedAccessAuthorizationRuleResource(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'rights': {'key': 'properties.rights', 'type': '[str]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "rights": {"key": "properties.rights", "type": "[str]"}, } def __init__( @@ -1285,32 +1240,32 @@ def __init__( :keyword rights: The rights associated with the rule. :paramtype rights: list[str or ~azure.mgmt.servicebus.v2015_08_01.models.AccessRights] """ - super(SharedAccessAuthorizationRuleResource, self).__init__(location=location, **kwargs) + super().__init__(location=location, **kwargs) self.rights = rights -class Sku(msrest.serialization.Model): +class Sku(_serialization.Model): """SKU of the namespace. All required parameters must be populated in order to send to Azure. - :ivar name: Name of this SKU. Known values are: "Basic", "Standard", "Premium". + :ivar name: Name of this SKU. Known values are: "Basic", "Standard", and "Premium". :vartype name: str or ~azure.mgmt.servicebus.v2015_08_01.models.SkuName - :ivar tier: Required. The billing tier of this particular SKU. Known values are: "Basic", - "Standard", "Premium". + :ivar tier: The billing tier of this particular SKU. Required. Known values are: "Basic", + "Standard", and "Premium". :vartype tier: str or ~azure.mgmt.servicebus.v2015_08_01.models.SkuTier :ivar capacity: The specified messaging units for the tier. :vartype capacity: int """ _validation = { - 'tier': {'required': True}, + "tier": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'capacity': {'key': 'capacity', 'type': 'int'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "capacity": {"key": "capacity", "type": "int"}, } def __init__( @@ -1322,28 +1277,28 @@ def __init__( **kwargs ): """ - :keyword name: Name of this SKU. Known values are: "Basic", "Standard", "Premium". + :keyword name: Name of this SKU. Known values are: "Basic", "Standard", and "Premium". :paramtype name: str or ~azure.mgmt.servicebus.v2015_08_01.models.SkuName - :keyword tier: Required. The billing tier of this particular SKU. Known values are: "Basic", - "Standard", "Premium". + :keyword tier: The billing tier of this particular SKU. Required. Known values are: "Basic", + "Standard", and "Premium". :paramtype tier: str or ~azure.mgmt.servicebus.v2015_08_01.models.SkuTier :keyword capacity: The specified messaging units for the tier. :paramtype capacity: int """ - super(Sku, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.tier = tier self.capacity = capacity -class SubscriptionCreateOrUpdateParameters(msrest.serialization.Model): +class SubscriptionCreateOrUpdateParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes """Parameters supplied to the Create Or Update Subscription operation. 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 location: Required. Subscription data center location. + :ivar location: Subscription data center location. Required. :vartype location: str :ivar type: Resource manager type of the resource. :vartype type: str @@ -1370,7 +1325,7 @@ class SubscriptionCreateOrUpdateParameters(msrest.serialization.Model): are enabled. :vartype enable_batched_operations: bool :ivar entity_availability_status: Entity availability status for the topic. Known values are: - "Available", "Limited", "Renaming", "Restoring", "Unknown". + "Available", "Limited", "Renaming", "Restoring", and "Unknown". :vartype entity_availability_status: str or ~azure.mgmt.servicebus.v2015_08_01.models.EntityAvailabilityStatus :ivar is_read_only: Value that indicates whether the entity description is read-only. @@ -1380,45 +1335,48 @@ class SubscriptionCreateOrUpdateParameters(msrest.serialization.Model): :ivar max_delivery_count: Number of maximum deliveries. :vartype max_delivery_count: int :ivar message_count: Number of messages. - :vartype message_count: long + :vartype message_count: int :ivar requires_session: Value indicating if a subscription supports the concept of sessions. :vartype requires_session: bool :ivar status: Enumerates the possible values for the status of a messaging entity. Known values are: "Active", "Creating", "Deleting", "Disabled", "ReceiveDisabled", "Renaming", "Restoring", - "SendDisabled", "Unknown". + "SendDisabled", and "Unknown". :vartype status: str or ~azure.mgmt.servicebus.v2015_08_01.models.EntityStatus :ivar updated_at: The exact time the message was updated. :vartype updated_at: ~datetime.datetime """ _validation = { - 'location': {'required': True}, - 'accessed_at': {'readonly': True}, - 'count_details': {'readonly': True}, - 'created_at': {'readonly': True}, - 'message_count': {'readonly': True}, - 'updated_at': {'readonly': True}, + "location": {"required": True}, + "accessed_at": {"readonly": True}, + "count_details": {"readonly": True}, + "created_at": {"readonly": True}, + "message_count": {"readonly": True}, + "updated_at": {"readonly": True}, } _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'accessed_at': {'key': 'properties.accessedAt', 'type': 'iso-8601'}, - 'auto_delete_on_idle': {'key': 'properties.autoDeleteOnIdle', 'type': 'str'}, - 'count_details': {'key': 'properties.countDetails', 'type': 'MessageCountDetails'}, - 'created_at': {'key': 'properties.createdAt', 'type': 'iso-8601'}, - 'default_message_time_to_live': {'key': 'properties.defaultMessageTimeToLive', 'type': 'str'}, - 'dead_lettering_on_filter_evaluation_exceptions': {'key': 'properties.deadLetteringOnFilterEvaluationExceptions', 'type': 'bool'}, - 'dead_lettering_on_message_expiration': {'key': 'properties.deadLetteringOnMessageExpiration', 'type': 'bool'}, - 'enable_batched_operations': {'key': 'properties.enableBatchedOperations', 'type': 'bool'}, - 'entity_availability_status': {'key': 'properties.entityAvailabilityStatus', 'type': 'str'}, - 'is_read_only': {'key': 'properties.isReadOnly', 'type': 'bool'}, - 'lock_duration': {'key': 'properties.lockDuration', 'type': 'str'}, - 'max_delivery_count': {'key': 'properties.maxDeliveryCount', 'type': 'int'}, - 'message_count': {'key': 'properties.messageCount', 'type': 'long'}, - 'requires_session': {'key': 'properties.requiresSession', 'type': 'bool'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'updated_at': {'key': 'properties.updatedAt', 'type': 'iso-8601'}, + "location": {"key": "location", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "accessed_at": {"key": "properties.accessedAt", "type": "iso-8601"}, + "auto_delete_on_idle": {"key": "properties.autoDeleteOnIdle", "type": "str"}, + "count_details": {"key": "properties.countDetails", "type": "MessageCountDetails"}, + "created_at": {"key": "properties.createdAt", "type": "iso-8601"}, + "default_message_time_to_live": {"key": "properties.defaultMessageTimeToLive", "type": "str"}, + "dead_lettering_on_filter_evaluation_exceptions": { + "key": "properties.deadLetteringOnFilterEvaluationExceptions", + "type": "bool", + }, + "dead_lettering_on_message_expiration": {"key": "properties.deadLetteringOnMessageExpiration", "type": "bool"}, + "enable_batched_operations": {"key": "properties.enableBatchedOperations", "type": "bool"}, + "entity_availability_status": {"key": "properties.entityAvailabilityStatus", "type": "str"}, + "is_read_only": {"key": "properties.isReadOnly", "type": "bool"}, + "lock_duration": {"key": "properties.lockDuration", "type": "str"}, + "max_delivery_count": {"key": "properties.maxDeliveryCount", "type": "int"}, + "message_count": {"key": "properties.messageCount", "type": "int"}, + "requires_session": {"key": "properties.requiresSession", "type": "bool"}, + "status": {"key": "properties.status", "type": "str"}, + "updated_at": {"key": "properties.updatedAt", "type": "iso-8601"}, } def __init__( @@ -1440,7 +1398,7 @@ def __init__( **kwargs ): """ - :keyword location: Required. Subscription data center location. + :keyword location: Subscription data center location. Required. :paramtype location: str :keyword type: Resource manager type of the resource. :paramtype type: str @@ -1461,7 +1419,7 @@ def __init__( are enabled. :paramtype enable_batched_operations: bool :keyword entity_availability_status: Entity availability status for the topic. Known values - are: "Available", "Limited", "Renaming", "Restoring", "Unknown". + are: "Available", "Limited", "Renaming", "Restoring", and "Unknown". :paramtype entity_availability_status: str or ~azure.mgmt.servicebus.v2015_08_01.models.EntityAvailabilityStatus :keyword is_read_only: Value that indicates whether the entity description is read-only. @@ -1474,10 +1432,10 @@ def __init__( :paramtype requires_session: bool :keyword status: Enumerates the possible values for the status of a messaging entity. Known values are: "Active", "Creating", "Deleting", "Disabled", "ReceiveDisabled", "Renaming", - "Restoring", "SendDisabled", "Unknown". + "Restoring", "SendDisabled", and "Unknown". :paramtype status: str or ~azure.mgmt.servicebus.v2015_08_01.models.EntityStatus """ - super(SubscriptionCreateOrUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.type = type self.accessed_at = None @@ -1498,7 +1456,7 @@ def __init__( self.updated_at = None -class SubscriptionListResult(msrest.serialization.Model): +class SubscriptionListResult(_serialization.Model): """The response to the List Subscriptions operation. :ivar value: Result of the List Subscriptions operation. @@ -1509,16 +1467,12 @@ class SubscriptionListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[SubscriptionResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SubscriptionResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["_models.SubscriptionResource"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.SubscriptionResource"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Result of the List Subscriptions operation. @@ -1527,12 +1481,12 @@ def __init__( list of subscriptions. :paramtype next_link: str """ - super(SubscriptionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class SubscriptionResource(Resource): +class SubscriptionResource(Resource): # pylint: disable=too-many-instance-attributes """Description of subscription resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -1568,7 +1522,7 @@ class SubscriptionResource(Resource): are enabled. :vartype enable_batched_operations: bool :ivar entity_availability_status: Entity availability status for the topic. Known values are: - "Available", "Limited", "Renaming", "Restoring", "Unknown". + "Available", "Limited", "Renaming", "Restoring", and "Unknown". :vartype entity_availability_status: str or ~azure.mgmt.servicebus.v2015_08_01.models.EntityAvailabilityStatus :ivar is_read_only: Value that indicates whether the entity description is read-only. @@ -1578,49 +1532,52 @@ class SubscriptionResource(Resource): :ivar max_delivery_count: Number of maximum deliveries. :vartype max_delivery_count: int :ivar message_count: Number of messages. - :vartype message_count: long + :vartype message_count: int :ivar requires_session: Value indicating if a subscription supports the concept of sessions. :vartype requires_session: bool :ivar status: Enumerates the possible values for the status of a messaging entity. Known values are: "Active", "Creating", "Deleting", "Disabled", "ReceiveDisabled", "Renaming", "Restoring", - "SendDisabled", "Unknown". + "SendDisabled", and "Unknown". :vartype status: str or ~azure.mgmt.servicebus.v2015_08_01.models.EntityStatus :ivar updated_at: The exact time the message was updated. :vartype updated_at: ~datetime.datetime """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'accessed_at': {'readonly': True}, - 'count_details': {'readonly': True}, - 'created_at': {'readonly': True}, - 'message_count': {'readonly': True}, - 'updated_at': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "accessed_at": {"readonly": True}, + "count_details": {"readonly": True}, + "created_at": {"readonly": True}, + "message_count": {"readonly": True}, + "updated_at": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'accessed_at': {'key': 'properties.accessedAt', 'type': 'iso-8601'}, - 'auto_delete_on_idle': {'key': 'properties.autoDeleteOnIdle', 'type': 'str'}, - 'count_details': {'key': 'properties.countDetails', 'type': 'MessageCountDetails'}, - 'created_at': {'key': 'properties.createdAt', 'type': 'iso-8601'}, - 'default_message_time_to_live': {'key': 'properties.defaultMessageTimeToLive', 'type': 'str'}, - 'dead_lettering_on_filter_evaluation_exceptions': {'key': 'properties.deadLetteringOnFilterEvaluationExceptions', 'type': 'bool'}, - 'dead_lettering_on_message_expiration': {'key': 'properties.deadLetteringOnMessageExpiration', 'type': 'bool'}, - 'enable_batched_operations': {'key': 'properties.enableBatchedOperations', 'type': 'bool'}, - 'entity_availability_status': {'key': 'properties.entityAvailabilityStatus', 'type': 'str'}, - 'is_read_only': {'key': 'properties.isReadOnly', 'type': 'bool'}, - 'lock_duration': {'key': 'properties.lockDuration', 'type': 'str'}, - 'max_delivery_count': {'key': 'properties.maxDeliveryCount', 'type': 'int'}, - 'message_count': {'key': 'properties.messageCount', 'type': 'long'}, - 'requires_session': {'key': 'properties.requiresSession', 'type': 'bool'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'updated_at': {'key': 'properties.updatedAt', 'type': 'iso-8601'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "accessed_at": {"key": "properties.accessedAt", "type": "iso-8601"}, + "auto_delete_on_idle": {"key": "properties.autoDeleteOnIdle", "type": "str"}, + "count_details": {"key": "properties.countDetails", "type": "MessageCountDetails"}, + "created_at": {"key": "properties.createdAt", "type": "iso-8601"}, + "default_message_time_to_live": {"key": "properties.defaultMessageTimeToLive", "type": "str"}, + "dead_lettering_on_filter_evaluation_exceptions": { + "key": "properties.deadLetteringOnFilterEvaluationExceptions", + "type": "bool", + }, + "dead_lettering_on_message_expiration": {"key": "properties.deadLetteringOnMessageExpiration", "type": "bool"}, + "enable_batched_operations": {"key": "properties.enableBatchedOperations", "type": "bool"}, + "entity_availability_status": {"key": "properties.entityAvailabilityStatus", "type": "str"}, + "is_read_only": {"key": "properties.isReadOnly", "type": "bool"}, + "lock_duration": {"key": "properties.lockDuration", "type": "str"}, + "max_delivery_count": {"key": "properties.maxDeliveryCount", "type": "int"}, + "message_count": {"key": "properties.messageCount", "type": "int"}, + "requires_session": {"key": "properties.requiresSession", "type": "bool"}, + "status": {"key": "properties.status", "type": "str"}, + "updated_at": {"key": "properties.updatedAt", "type": "iso-8601"}, } def __init__( @@ -1660,7 +1617,7 @@ def __init__( are enabled. :paramtype enable_batched_operations: bool :keyword entity_availability_status: Entity availability status for the topic. Known values - are: "Available", "Limited", "Renaming", "Restoring", "Unknown". + are: "Available", "Limited", "Renaming", "Restoring", and "Unknown". :paramtype entity_availability_status: str or ~azure.mgmt.servicebus.v2015_08_01.models.EntityAvailabilityStatus :keyword is_read_only: Value that indicates whether the entity description is read-only. @@ -1673,10 +1630,10 @@ def __init__( :paramtype requires_session: bool :keyword status: Enumerates the possible values for the status of a messaging entity. Known values are: "Active", "Creating", "Deleting", "Disabled", "ReceiveDisabled", "Renaming", - "Restoring", "SendDisabled", "Unknown". + "Restoring", "SendDisabled", and "Unknown". :paramtype status: str or ~azure.mgmt.servicebus.v2015_08_01.models.EntityStatus """ - super(SubscriptionResource, self).__init__(location=location, **kwargs) + super().__init__(location=location, **kwargs) self.accessed_at = None self.auto_delete_on_idle = auto_delete_on_idle self.count_details = None @@ -1695,7 +1652,7 @@ def __init__( self.updated_at = None -class TopicCreateOrUpdateParameters(msrest.serialization.Model): +class TopicCreateOrUpdateParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes """Parameters supplied to the Create Or Update Topic operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -1704,7 +1661,7 @@ class TopicCreateOrUpdateParameters(msrest.serialization.Model): :ivar name: Topic name. :vartype name: str - :ivar location: Required. Location of the resource. + :ivar location: Location of the resource. Required. :vartype location: str :ivar accessed_at: Last time the message was sent, or a request was received, for this topic. :vartype accessed_at: ~datetime.datetime @@ -1712,7 +1669,7 @@ class TopicCreateOrUpdateParameters(msrest.serialization.Model): deleted. The minimum duration is 5 minutes. :vartype auto_delete_on_idle: str :ivar entity_availability_status: Entity availability status for the topic. Known values are: - "Available", "Limited", "Renaming", "Restoring", "Unknown". + "Available", "Limited", "Renaming", "Restoring", and "Unknown". :vartype entity_availability_status: str or ~azure.mgmt.servicebus.v2015_08_01.models.EntityAvailabilityStatus :ivar created_at: Exact time the message was created. @@ -1745,15 +1702,15 @@ class TopicCreateOrUpdateParameters(msrest.serialization.Model): :vartype is_express: bool :ivar max_size_in_megabytes: Maximum size of the topic in megabytes, which is the size of the memory allocated for the topic. - :vartype max_size_in_megabytes: long + :vartype max_size_in_megabytes: int :ivar requires_duplicate_detection: Value indicating if this topic requires duplicate detection. :vartype requires_duplicate_detection: bool :ivar size_in_bytes: Size of the topic, in bytes. - :vartype size_in_bytes: long + :vartype size_in_bytes: int :ivar status: Enumerates the possible values for the status of a messaging entity. Known values are: "Active", "Creating", "Deleting", "Disabled", "ReceiveDisabled", "Renaming", "Restoring", - "SendDisabled", "Unknown". + "SendDisabled", and "Unknown". :vartype status: str or ~azure.mgmt.servicebus.v2015_08_01.models.EntityStatus :ivar subscription_count: Number of subscriptions. :vartype subscription_count: int @@ -1764,38 +1721,41 @@ class TopicCreateOrUpdateParameters(msrest.serialization.Model): """ _validation = { - 'location': {'required': True}, - 'accessed_at': {'readonly': True}, - 'created_at': {'readonly': True}, - 'count_details': {'readonly': True}, - 'size_in_bytes': {'readonly': True}, - 'subscription_count': {'readonly': True}, - 'updated_at': {'readonly': True}, + "location": {"required": True}, + "accessed_at": {"readonly": True}, + "created_at": {"readonly": True}, + "count_details": {"readonly": True}, + "size_in_bytes": {"readonly": True}, + "subscription_count": {"readonly": True}, + "updated_at": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'accessed_at': {'key': 'properties.accessedAt', 'type': 'iso-8601'}, - 'auto_delete_on_idle': {'key': 'properties.autoDeleteOnIdle', 'type': 'str'}, - 'entity_availability_status': {'key': 'properties.entityAvailabilityStatus', 'type': 'str'}, - 'created_at': {'key': 'properties.createdAt', 'type': 'iso-8601'}, - 'count_details': {'key': 'properties.countDetails', 'type': 'MessageCountDetails'}, - 'default_message_time_to_live': {'key': 'properties.defaultMessageTimeToLive', 'type': 'str'}, - 'duplicate_detection_history_time_window': {'key': 'properties.duplicateDetectionHistoryTimeWindow', 'type': 'str'}, - 'enable_batched_operations': {'key': 'properties.enableBatchedOperations', 'type': 'bool'}, - 'enable_express': {'key': 'properties.enableExpress', 'type': 'bool'}, - 'enable_partitioning': {'key': 'properties.enablePartitioning', 'type': 'bool'}, - 'filtering_messages_before_publishing': {'key': 'properties.filteringMessagesBeforePublishing', 'type': 'bool'}, - 'is_anonymous_accessible': {'key': 'properties.isAnonymousAccessible', 'type': 'bool'}, - 'is_express': {'key': 'properties.isExpress', 'type': 'bool'}, - 'max_size_in_megabytes': {'key': 'properties.maxSizeInMegabytes', 'type': 'long'}, - 'requires_duplicate_detection': {'key': 'properties.requiresDuplicateDetection', 'type': 'bool'}, - 'size_in_bytes': {'key': 'properties.sizeInBytes', 'type': 'long'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'subscription_count': {'key': 'properties.subscriptionCount', 'type': 'int'}, - 'support_ordering': {'key': 'properties.supportOrdering', 'type': 'bool'}, - 'updated_at': {'key': 'properties.updatedAt', 'type': 'iso-8601'}, + "name": {"key": "name", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "accessed_at": {"key": "properties.accessedAt", "type": "iso-8601"}, + "auto_delete_on_idle": {"key": "properties.autoDeleteOnIdle", "type": "str"}, + "entity_availability_status": {"key": "properties.entityAvailabilityStatus", "type": "str"}, + "created_at": {"key": "properties.createdAt", "type": "iso-8601"}, + "count_details": {"key": "properties.countDetails", "type": "MessageCountDetails"}, + "default_message_time_to_live": {"key": "properties.defaultMessageTimeToLive", "type": "str"}, + "duplicate_detection_history_time_window": { + "key": "properties.duplicateDetectionHistoryTimeWindow", + "type": "str", + }, + "enable_batched_operations": {"key": "properties.enableBatchedOperations", "type": "bool"}, + "enable_express": {"key": "properties.enableExpress", "type": "bool"}, + "enable_partitioning": {"key": "properties.enablePartitioning", "type": "bool"}, + "filtering_messages_before_publishing": {"key": "properties.filteringMessagesBeforePublishing", "type": "bool"}, + "is_anonymous_accessible": {"key": "properties.isAnonymousAccessible", "type": "bool"}, + "is_express": {"key": "properties.isExpress", "type": "bool"}, + "max_size_in_megabytes": {"key": "properties.maxSizeInMegabytes", "type": "int"}, + "requires_duplicate_detection": {"key": "properties.requiresDuplicateDetection", "type": "bool"}, + "size_in_bytes": {"key": "properties.sizeInBytes", "type": "int"}, + "status": {"key": "properties.status", "type": "str"}, + "subscription_count": {"key": "properties.subscriptionCount", "type": "int"}, + "support_ordering": {"key": "properties.supportOrdering", "type": "bool"}, + "updated_at": {"key": "properties.updatedAt", "type": "iso-8601"}, } def __init__( @@ -1822,13 +1782,13 @@ def __init__( """ :keyword name: Topic name. :paramtype name: str - :keyword location: Required. Location of the resource. + :keyword location: Location of the resource. Required. :paramtype location: str :keyword auto_delete_on_idle: TimeSpan idle interval after which the topic is automatically deleted. The minimum duration is 5 minutes. :paramtype auto_delete_on_idle: str :keyword entity_availability_status: Entity availability status for the topic. Known values - are: "Available", "Limited", "Renaming", "Restoring", "Unknown". + are: "Available", "Limited", "Renaming", "Restoring", and "Unknown". :paramtype entity_availability_status: str or ~azure.mgmt.servicebus.v2015_08_01.models.EntityAvailabilityStatus :keyword default_message_time_to_live: Default message time to live value. This is the duration @@ -1857,18 +1817,18 @@ def __init__( :paramtype is_express: bool :keyword max_size_in_megabytes: Maximum size of the topic in megabytes, which is the size of the memory allocated for the topic. - :paramtype max_size_in_megabytes: long + :paramtype max_size_in_megabytes: int :keyword requires_duplicate_detection: Value indicating if this topic requires duplicate detection. :paramtype requires_duplicate_detection: bool :keyword status: Enumerates the possible values for the status of a messaging entity. Known values are: "Active", "Creating", "Deleting", "Disabled", "ReceiveDisabled", "Renaming", - "Restoring", "SendDisabled", "Unknown". + "Restoring", "SendDisabled", and "Unknown". :paramtype status: str or ~azure.mgmt.servicebus.v2015_08_01.models.EntityStatus :keyword support_ordering: Value that indicates whether the topic supports ordering. :paramtype support_ordering: bool """ - super(TopicCreateOrUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.location = location self.accessed_at = None @@ -1893,7 +1853,7 @@ def __init__( self.updated_at = None -class TopicListResult(msrest.serialization.Model): +class TopicListResult(_serialization.Model): """The response to the List Topics operation. :ivar value: Result of the List Topics operation. @@ -1904,16 +1864,12 @@ class TopicListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[TopicResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[TopicResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["_models.TopicResource"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.TopicResource"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Result of the List Topics operation. @@ -1922,12 +1878,12 @@ def __init__( list of topics. :paramtype next_link: str """ - super(TopicListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class TopicResource(Resource): +class TopicResource(Resource): # pylint: disable=too-many-instance-attributes """Description of topic resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -1946,7 +1902,7 @@ class TopicResource(Resource): deleted. The minimum duration is 5 minutes. :vartype auto_delete_on_idle: str :ivar entity_availability_status: Entity availability status for the topic. Known values are: - "Available", "Limited", "Renaming", "Restoring", "Unknown". + "Available", "Limited", "Renaming", "Restoring", and "Unknown". :vartype entity_availability_status: str or ~azure.mgmt.servicebus.v2015_08_01.models.EntityAvailabilityStatus :ivar created_at: Exact time the message was created. @@ -1979,15 +1935,15 @@ class TopicResource(Resource): :vartype is_express: bool :ivar max_size_in_megabytes: Maximum size of the topic in megabytes, which is the size of the memory allocated for the topic. - :vartype max_size_in_megabytes: long + :vartype max_size_in_megabytes: int :ivar requires_duplicate_detection: Value indicating if this topic requires duplicate detection. :vartype requires_duplicate_detection: bool :ivar size_in_bytes: Size of the topic, in bytes. - :vartype size_in_bytes: long + :vartype size_in_bytes: int :ivar status: Enumerates the possible values for the status of a messaging entity. Known values are: "Active", "Creating", "Deleting", "Disabled", "ReceiveDisabled", "Renaming", "Restoring", - "SendDisabled", "Unknown". + "SendDisabled", and "Unknown". :vartype status: str or ~azure.mgmt.servicebus.v2015_08_01.models.EntityStatus :ivar subscription_count: Number of subscriptions. :vartype subscription_count: int @@ -1998,45 +1954,48 @@ class TopicResource(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'accessed_at': {'readonly': True}, - 'created_at': {'readonly': True}, - 'count_details': {'readonly': True}, - 'size_in_bytes': {'readonly': True}, - 'subscription_count': {'readonly': True}, - 'updated_at': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "accessed_at": {"readonly": True}, + "created_at": {"readonly": True}, + "count_details": {"readonly": True}, + "size_in_bytes": {"readonly": True}, + "subscription_count": {"readonly": True}, + "updated_at": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'accessed_at': {'key': 'properties.accessedAt', 'type': 'iso-8601'}, - 'auto_delete_on_idle': {'key': 'properties.autoDeleteOnIdle', 'type': 'str'}, - 'entity_availability_status': {'key': 'properties.entityAvailabilityStatus', 'type': 'str'}, - 'created_at': {'key': 'properties.createdAt', 'type': 'iso-8601'}, - 'count_details': {'key': 'properties.countDetails', 'type': 'MessageCountDetails'}, - 'default_message_time_to_live': {'key': 'properties.defaultMessageTimeToLive', 'type': 'str'}, - 'duplicate_detection_history_time_window': {'key': 'properties.duplicateDetectionHistoryTimeWindow', 'type': 'str'}, - 'enable_batched_operations': {'key': 'properties.enableBatchedOperations', 'type': 'bool'}, - 'enable_express': {'key': 'properties.enableExpress', 'type': 'bool'}, - 'enable_partitioning': {'key': 'properties.enablePartitioning', 'type': 'bool'}, - 'filtering_messages_before_publishing': {'key': 'properties.filteringMessagesBeforePublishing', 'type': 'bool'}, - 'is_anonymous_accessible': {'key': 'properties.isAnonymousAccessible', 'type': 'bool'}, - 'is_express': {'key': 'properties.isExpress', 'type': 'bool'}, - 'max_size_in_megabytes': {'key': 'properties.maxSizeInMegabytes', 'type': 'long'}, - 'requires_duplicate_detection': {'key': 'properties.requiresDuplicateDetection', 'type': 'bool'}, - 'size_in_bytes': {'key': 'properties.sizeInBytes', 'type': 'long'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'subscription_count': {'key': 'properties.subscriptionCount', 'type': 'int'}, - 'support_ordering': {'key': 'properties.supportOrdering', 'type': 'bool'}, - 'updated_at': {'key': 'properties.updatedAt', 'type': 'iso-8601'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "accessed_at": {"key": "properties.accessedAt", "type": "iso-8601"}, + "auto_delete_on_idle": {"key": "properties.autoDeleteOnIdle", "type": "str"}, + "entity_availability_status": {"key": "properties.entityAvailabilityStatus", "type": "str"}, + "created_at": {"key": "properties.createdAt", "type": "iso-8601"}, + "count_details": {"key": "properties.countDetails", "type": "MessageCountDetails"}, + "default_message_time_to_live": {"key": "properties.defaultMessageTimeToLive", "type": "str"}, + "duplicate_detection_history_time_window": { + "key": "properties.duplicateDetectionHistoryTimeWindow", + "type": "str", + }, + "enable_batched_operations": {"key": "properties.enableBatchedOperations", "type": "bool"}, + "enable_express": {"key": "properties.enableExpress", "type": "bool"}, + "enable_partitioning": {"key": "properties.enablePartitioning", "type": "bool"}, + "filtering_messages_before_publishing": {"key": "properties.filteringMessagesBeforePublishing", "type": "bool"}, + "is_anonymous_accessible": {"key": "properties.isAnonymousAccessible", "type": "bool"}, + "is_express": {"key": "properties.isExpress", "type": "bool"}, + "max_size_in_megabytes": {"key": "properties.maxSizeInMegabytes", "type": "int"}, + "requires_duplicate_detection": {"key": "properties.requiresDuplicateDetection", "type": "bool"}, + "size_in_bytes": {"key": "properties.sizeInBytes", "type": "int"}, + "status": {"key": "properties.status", "type": "str"}, + "subscription_count": {"key": "properties.subscriptionCount", "type": "int"}, + "support_ordering": {"key": "properties.supportOrdering", "type": "bool"}, + "updated_at": {"key": "properties.updatedAt", "type": "iso-8601"}, } - def __init__( + def __init__( # pylint: disable=too-many-locals self, *, location: Optional[str] = None, @@ -2063,7 +2022,7 @@ def __init__( deleted. The minimum duration is 5 minutes. :paramtype auto_delete_on_idle: str :keyword entity_availability_status: Entity availability status for the topic. Known values - are: "Available", "Limited", "Renaming", "Restoring", "Unknown". + are: "Available", "Limited", "Renaming", "Restoring", and "Unknown". :paramtype entity_availability_status: str or ~azure.mgmt.servicebus.v2015_08_01.models.EntityAvailabilityStatus :keyword default_message_time_to_live: Default message time to live value. This is the duration @@ -2092,18 +2051,18 @@ def __init__( :paramtype is_express: bool :keyword max_size_in_megabytes: Maximum size of the topic in megabytes, which is the size of the memory allocated for the topic. - :paramtype max_size_in_megabytes: long + :paramtype max_size_in_megabytes: int :keyword requires_duplicate_detection: Value indicating if this topic requires duplicate detection. :paramtype requires_duplicate_detection: bool :keyword status: Enumerates the possible values for the status of a messaging entity. Known values are: "Active", "Creating", "Deleting", "Disabled", "ReceiveDisabled", "Renaming", - "Restoring", "SendDisabled", "Unknown". + "Restoring", "SendDisabled", and "Unknown". :paramtype status: str or ~azure.mgmt.servicebus.v2015_08_01.models.EntityStatus :keyword support_ordering: Value that indicates whether the topic supports ordering. :paramtype support_ordering: bool """ - super(TopicResource, self).__init__(location=location, **kwargs) + super().__init__(location=location, **kwargs) self.accessed_at = None self.auto_delete_on_idle = auto_delete_on_idle self.entity_availability_status = entity_availability_status diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/models/_patch.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/models/_patch.py index 0ad201a8c586e..f7dd32510333d 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/models/_patch.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/models/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/models/_service_bus_management_client_enums.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/models/_service_bus_management_client_enums.py index c594d57bdc646..cbd05dcaf049f 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/models/_service_bus_management_client_enums.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/models/_service_bus_management_client_enums.py @@ -11,14 +11,15 @@ class AccessRights(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """AccessRights.""" MANAGE = "Manage" SEND = "Send" LISTEN = "Listen" + class EntityAvailabilityStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Entity availability status. - """ + """Entity availability status.""" AVAILABLE = "Available" LIMITED = "Limited" @@ -26,9 +27,9 @@ class EntityAvailabilityStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): RESTORING = "Restoring" UNKNOWN = "Unknown" + class EntityStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Entity status. - """ + """Entity status.""" ACTIVE = "Active" CREATING = "Creating" @@ -40,9 +41,9 @@ class EntityStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): SEND_DISABLED = "SendDisabled" UNKNOWN = "Unknown" + class NamespaceState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """State of the namespace. - """ + """State of the namespace.""" UNKNOWN = "Unknown" CREATING = "Creating" @@ -58,32 +59,32 @@ class NamespaceState(str, Enum, metaclass=CaseInsensitiveEnumMeta): REMOVED = "Removed" FAILED = "Failed" + class Policykey(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Key that needs to be regenerated. - """ + """Key that needs to be regenerated.""" PRIMARY_KEY = "PrimaryKey" SECONDARY_KEY = "SecondaryKey" + class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Name of this SKU. - """ + """Name of this SKU.""" BASIC = "Basic" STANDARD = "Standard" PREMIUM = "Premium" + class SkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The billing tier of this particular SKU. - """ + """The billing tier of this particular SKU.""" BASIC = "Basic" STANDARD = "Standard" PREMIUM = "Premium" + class UnavailableReason(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the reason for the unavailability of the service. - """ + """Specifies the reason for the unavailability of the service.""" NONE = "None" INVALID_NAME = "InvalidName" diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/operations/__init__.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/operations/__init__.py index b0ee9242d9859..2051d27d13ae4 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/operations/__init__.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/operations/__init__.py @@ -13,14 +13,15 @@ from ._subscriptions_operations import SubscriptionsOperations from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'NamespacesOperations', - 'QueuesOperations', - 'TopicsOperations', - 'SubscriptionsOperations', + "Operations", + "NamespacesOperations", + "QueuesOperations", + "TopicsOperations", + "SubscriptionsOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/operations/_namespaces_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/operations/_namespaces_operations.py index dede4df2a3740..12c26eb8839f1 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/operations/_namespaces_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/operations/_namespaces_operations.py @@ -6,11 +6,18 @@ # 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, Union, cast - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -22,518 +29,447 @@ 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') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_check_name_availability_request( - subscription_id: str, - *, - json: Optional[_models.CheckNameAvailability] = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: + +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', "2015-08-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: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/CheckNameAvailability") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/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: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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, - 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_by_subscription_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +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', "2015-08-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/namespaces") 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: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _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: + +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', "2015-08-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _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( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - *, - json: Optional[_models.NamespaceCreateOrUpdateParameters] = None, - content: Any = None, - **kwargs: Any + +def build_create_or_update_request( + resource_group_name: str, namespace_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', "2015-08-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: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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, - 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( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - **kwargs: Any + +def build_delete_request( + resource_group_name: str, namespace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_get_request( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_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', "2015-08-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _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, - namespace_name: str, - subscription_id: str, - *, - json: Optional[_models.NamespaceUpdateParameters] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_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', "2015-08-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: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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, - 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_list_authorization_rules_request( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_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', "2015-08-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_authorization_rule_request( - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - subscription_id: str, - *, - json: Optional[_models.SharedAccessAuthorizationRuleCreateOrUpdateParameters] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_name: str, authorization_rule_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', "2015-08-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: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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, - 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_authorization_rule_request( - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, authorization_rule_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_get_authorization_rule_request( - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, authorization_rule_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', "2015-08-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_keys_request( - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, authorization_rule_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', "2015-08-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/listKeys") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/listKeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_regenerate_keys_request( - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - subscription_id: str, - *, - json: Optional[_models.RegenerateKeysParameters] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_name: str, authorization_rule_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', "2015-08-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: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/regenerateKeys") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/regenerateKeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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, - 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 NamespacesOperations: """ @@ -554,116 +490,166 @@ def __init__(self, *args, **kwargs): 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") + @overload + def check_name_availability( + self, parameters: _models.CheckNameAvailability, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param parameters: Parameters to check availability of the given namespace name. Required. + :type parameters: ~azure.mgmt.servicebus.v2015_08_01.models.CheckNameAvailability + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckNameAvailabilityResult or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param parameters: Parameters to check availability of the given namespace name. Required. + :type 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: CheckNameAvailabilityResult or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def check_name_availability( - self, - parameters: _models.CheckNameAvailability, - **kwargs: Any + self, parameters: Union[_models.CheckNameAvailability, IO], **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Check the give namespace name availability. - :param parameters: Parameters to check availability of the given namespace name. - :type parameters: ~azure.mgmt.servicebus.v2015_08_01.models.CheckNameAvailability + :param parameters: Parameters to check availability of the given namespace name. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2015_08_01.models.CheckNameAvailability 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: CheckNameAvailabilityResult, or the result of cls(response) + :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.CheckNameAvailabilityResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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', "2015-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.CheckNameAvailabilityResult] + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CheckNameAvailabilityResult] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'CheckNameAvailability') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "CheckNameAvailability") 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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # 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) - deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) + deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/CheckNameAvailability"} # type: ignore - + check_name_availability.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/CheckNameAvailability" + } @distributed_trace - def list_by_subscription( - self, - **kwargs: Any - ) -> Iterable[_models.NamespaceListResult]: + def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.NamespaceResource"]: """Gets all the available namespaces within the subscription, irrespective of the resource groups. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either NamespaceListResult or the result of cls(response) + :return: An iterator like instance of either NamespaceResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2015_08_01.models.NamespaceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2015_08_01.models.NamespaceResource] + :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', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.NamespaceListResult] + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + cls: ClsType[_models.NamespaceListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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'], + 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 + request.url = self._client.format_url(request.url) else: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -671,16 +657,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("NamespaceListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -690,64 +674,65 @@ 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.ServiceBus/namespaces"} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/namespaces"} @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable[_models.NamespaceListResult]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.NamespaceResource"]: """Gets the available namespaces within a resource group. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. 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 NamespaceListResult or the result of cls(response) + :return: An iterator like instance of either NamespaceResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2015_08_01.models.NamespaceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2015_08_01.models.NamespaceResource] + :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', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.NamespaceListResult] + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + cls: ClsType[_models.NamespaceListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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'], + 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 + request.url = self._client.format_url(request.url) else: - - 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=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -755,16 +740,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("NamespaceListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -774,52 +757,61 @@ 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.ServiceBus/namespaces"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces" + } def _create_or_update_initial( self, resource_group_name: str, namespace_name: str, - parameters: _models.NamespaceCreateOrUpdateParameters, + parameters: Union[_models.NamespaceCreateOrUpdateParameters, IO], **kwargs: Any ) -> Optional[_models.NamespaceResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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', "2015-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.NamespaceResource]] + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.NamespaceResource]] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'NamespaceCreateOrUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "NamespaceCreateOrUpdateParameters") - request = build_create_or_update_request_initial( + request = build_create_or_update_request( resource_group_name=resource_group_name, namespace_name=namespace_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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -828,36 +820,116 @@ def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('NamespaceResource', pipeline_response) + deserialized = self._deserialize("NamespaceResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('NamespaceResource', pipeline_response) + deserialized = self._deserialize("NamespaceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}" + } + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + namespace_name: str, + parameters: _models.NamespaceCreateOrUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.NamespaceResource]: + """Creates or updates a service namespace. Once created, this namespace's resource manifest is + immutable. This operation is idempotent. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to create a namespace resource. Required. + :type parameters: ~azure.mgmt.servicebus.v2015_08_01.models.NamespaceCreateOrUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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 NamespaceResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.servicebus.v2015_08_01.models.NamespaceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.NamespaceResource]: + """Creates or updates a service namespace. Once created, this namespace's resource manifest is + immutable. This operation is idempotent. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to create a namespace resource. Required. + :type 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 + :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 NamespaceResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.servicebus.v2015_08_01.models.NamespaceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( self, resource_group_name: str, namespace_name: str, - parameters: _models.NamespaceCreateOrUpdateParameters, + parameters: Union[_models.NamespaceCreateOrUpdateParameters, IO], **kwargs: Any ) -> LROPoller[_models.NamespaceResource]: """Creates or updates a service namespace. Once created, this namespace's resource manifest is immutable. This operation is idempotent. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: Parameters supplied to create a namespace resource. + :param parameters: Parameters supplied to create a namespace resource. Is either a model type + or a IO type. Required. :type parameters: ~azure.mgmt.servicebus.v2015_08_01.models.NamespaceCreateOrUpdateParameters + 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 @@ -870,96 +942,89 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.servicebus.v2015_08_01.models.NamespaceResource] - :raises: ~azure.core.exceptions.HttpResponseError + :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', "2015-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.NamespaceResource] - 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] + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.NamespaceResource] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._create_or_update_initial( # type: ignore + raw_result = self._create_or_update_initial( resource_group_name=resource_group_name, namespace_name=namespace_name, parameters=parameters, 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): - deserialized = self._deserialize('NamespaceResource', pipeline_response) + deserialized = self._deserialize("NamespaceResource", 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 + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}" + } def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, **kwargs: Any ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request_initial( + request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + 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 + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -969,22 +1034,18 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}" + } @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete(self, resource_group_name: str, namespace_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes an existing namespace. This operation also removes all associated resources under the namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_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. @@ -996,154 +1057,215 @@ def begin_delete( # pylint: disable=inconsistent-return-statements 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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: 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] + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, namespace_name=namespace_name, api_version=api_version, - 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 = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}" + } @distributed_trace - def get( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> _models.NamespaceResource: + def get(self, resource_group_name: str, namespace_name: str, **kwargs: Any) -> _models.NamespaceResource: """Gets a description for the specified namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: NamespaceResource, or the result of cls(response) + :return: NamespaceResource or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.NamespaceResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.NamespaceResource] + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + cls: ClsType[_models.NamespaceResource] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # 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) - deserialized = self._deserialize('NamespaceResource', pipeline_response) + deserialized = self._deserialize("NamespaceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}" + } - @distributed_trace + @overload def update( self, resource_group_name: str, namespace_name: str, parameters: _models.NamespaceUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> Optional[_models.NamespaceResource]: """Updates a service namespace. Once created, this namespace's resource manifest is immutable. This operation is idempotent. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: Parameters supplied to update a namespace resource. + :param parameters: Parameters supplied to update a namespace resource. Required. :type parameters: ~azure.mgmt.servicebus.v2015_08_01.models.NamespaceUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: NamespaceResource or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.NamespaceResource or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> Optional[_models.NamespaceResource]: + """Updates a service namespace. Once created, this namespace's resource manifest is immutable. + This operation is idempotent. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to update a namespace resource. Required. + :type 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: NamespaceResource or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.NamespaceResource or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + namespace_name: str, + parameters: Union[_models.NamespaceUpdateParameters, IO], + **kwargs: Any + ) -> Optional[_models.NamespaceResource]: + """Updates a service namespace. Once created, this namespace's resource manifest is immutable. + This operation is idempotent. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to update a namespace resource. Is either a model type + or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2015_08_01.models.NamespaceUpdateParameters 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: NamespaceResource, or the result of cls(response) + :return: NamespaceResource or None or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.NamespaceResource or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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', "2015-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.NamespaceResource]] + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.NamespaceResource]] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'NamespaceUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "NamespaceUpdateParameters") request = build_update_request( resource_group_name=resource_group_name, @@ -1152,18 +1274,18 @@ def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -1172,77 +1294,81 @@ def update( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('NamespaceResource', pipeline_response) + deserialized = self._deserialize("NamespaceResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('NamespaceResource', pipeline_response) + deserialized = self._deserialize("NamespaceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore - + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}" + } @distributed_trace def list_authorization_rules( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> Iterable[_models.SharedAccessAuthorizationRuleListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> Iterable["_models.SharedAccessAuthorizationRuleResource"]: """Gets the authorization rules for a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SharedAccessAuthorizationRuleListResult or the + :return: An iterator like instance of either SharedAccessAuthorizationRuleResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleResource] + :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', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SharedAccessAuthorizationRuleListResult] + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + cls: ClsType[_models.SharedAccessAuthorizationRuleListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_authorization_rules_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_authorization_rules.metadata['url'], + template_url=self.list_authorization_rules.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_authorization_rules_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -1250,16 +1376,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("SharedAccessAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1269,50 +1393,125 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_authorization_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules"} # type: ignore + list_authorization_rules.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules" + } - @distributed_trace + @overload def create_or_update_authorization_rule( self, resource_group_name: str, namespace_name: str, authorization_rule_name: str, parameters: _models.SharedAccessAuthorizationRuleCreateOrUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SharedAccessAuthorizationRuleResource: + """Creates or updates an authorization rule for a namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Required. + :type parameters: + ~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleCreateOrUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SharedAccessAuthorizationRuleResource or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SharedAccessAuthorizationRuleResource: + """Creates or updates an authorization rule for a namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Required. + :type 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: SharedAccessAuthorizationRuleResource or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: Union[_models.SharedAccessAuthorizationRuleCreateOrUpdateParameters, IO], **kwargs: Any ) -> _models.SharedAccessAuthorizationRuleResource: """Creates or updates an authorization rule for a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: The shared access authorization rule. + :param parameters: The shared access authorization rule. Is either a model type or a IO type. + Required. :type parameters: ~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleCreateOrUpdateParameters + 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: SharedAccessAuthorizationRuleResource, or the result of cls(response) + :return: SharedAccessAuthorizationRuleResource or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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', "2015-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SharedAccessAuthorizationRuleResource] + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SharedAccessAuthorizationRuleResource] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'SharedAccessAuthorizationRuleCreateOrUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SharedAccessAuthorizationRuleCreateOrUpdateParameters") request = build_create_or_update_authorization_rule_request( resource_group_name=resource_group_name, @@ -1322,85 +1521,83 @@ def create_or_update_authorization_rule( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_authorization_rule.metadata['url'], + content=_content, + template_url=self.create_or_update_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # 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) - deserialized = self._deserialize('SharedAccessAuthorizationRuleResource', pipeline_response) + deserialized = self._deserialize("SharedAccessAuthorizationRuleResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}"} # type: ignore - + create_or_update_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}" + } @distributed_trace def delete_authorization_rule( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, authorization_rule_name: str, **kwargs: Any ) -> None: """Deletes a namespace authorization rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_authorization_rule.metadata['url'], + template_url=self.delete_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1410,180 +1607,250 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}"} # type: ignore - + delete_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}" + } @distributed_trace def get_authorization_rule( - self, - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, authorization_rule_name: str, **kwargs: Any ) -> _models.SharedAccessAuthorizationRuleResource: """Gets an authorization rule for a namespace by rule name. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SharedAccessAuthorizationRuleResource, or the result of cls(response) + :return: SharedAccessAuthorizationRuleResource or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SharedAccessAuthorizationRuleResource] + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + cls: ClsType[_models.SharedAccessAuthorizationRuleResource] = kwargs.pop("cls", None) - request = build_get_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_authorization_rule.metadata['url'], + template_url=self.get_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # 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) - deserialized = self._deserialize('SharedAccessAuthorizationRuleResource', pipeline_response) + deserialized = self._deserialize("SharedAccessAuthorizationRuleResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}"} # type: ignore - + get_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}" + } @distributed_trace def list_keys( - self, - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, authorization_rule_name: str, **kwargs: Any ) -> _models.ResourceListKeys: """Gets the primary and secondary connection strings for the namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceListKeys, or the result of cls(response) + :return: ResourceListKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.ResourceListKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ResourceListKeys] + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + cls: ClsType[_models.ResourceListKeys] = kwargs.pop("cls", None) - request = build_list_keys_request( resource_group_name=resource_group_name, namespace_name=namespace_name, authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata['url'], + 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 + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # 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) - deserialized = self._deserialize('ResourceListKeys', pipeline_response) + deserialized = self._deserialize("ResourceListKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/listKeys"} # type: ignore - + list_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/listKeys" + } - @distributed_trace + @overload def regenerate_keys( self, resource_group_name: str, namespace_name: str, authorization_rule_name: str, parameters: _models.RegenerateKeysParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ResourceListKeys: """Regenerates the primary or secondary connection strings for the namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate the authorization rule. + :param parameters: Parameters supplied to regenerate the authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2015_08_01.models.RegenerateKeysParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceListKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.ResourceListKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ResourceListKeys: + """Regenerates the primary or secondary connection strings for the namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Required. + :type 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: ResourceListKeys, or the result of cls(response) + :return: ResourceListKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.ResourceListKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: Union[_models.RegenerateKeysParameters, IO], + **kwargs: Any + ) -> _models.ResourceListKeys: + """Regenerates the primary or secondary connection strings for the namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2015_08_01.models.RegenerateKeysParameters 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: ResourceListKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.ResourceListKeys + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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', "2015-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ResourceListKeys] + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ResourceListKeys] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'RegenerateKeysParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RegenerateKeysParameters") request = build_regenerate_keys_request( resource_group_name=resource_group_name, @@ -1593,30 +1860,31 @@ def regenerate_keys( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_keys.metadata['url'], + content=_content, + template_url=self.regenerate_keys.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # 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) - deserialized = self._deserialize('ResourceListKeys', pipeline_response) + deserialized = self._deserialize("ResourceListKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/regenerateKeys"} # type: ignore - + regenerate_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/regenerateKeys" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/operations/_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/operations/_operations.py index 2eb93e39c63f3..3f3dbe4e489c6 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/operations/_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/operations/_operations.py @@ -6,11 +6,18 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,38 +27,38 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +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: + +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', "2015-08-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.ServiceBus/operations") # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class Operations: """ @@ -72,52 +79,56 @@ def __init__(self, *args, **kwargs): 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 ServiceBus 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.servicebus.v2015_08_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.servicebus.v2015_08_01.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', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_request( - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -125,16 +136,14 @@ 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) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -144,8 +153,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.ServiceBus/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.ServiceBus/operations"} diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/operations/_patch.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/operations/_patch.py index 0ad201a8c586e..f7dd32510333d 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/operations/_patch.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/operations/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/operations/_queues_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/operations/_queues_operations.py index a7935179f693d..f93e8bb23991b 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/operations/_queues_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/operations/_queues_operations.py @@ -6,11 +6,18 @@ # 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 msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,205 +27,184 @@ 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') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_all_request( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_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', "2015-08-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( - resource_group_name: str, - namespace_name: str, - queue_name: str, - subscription_id: str, - *, - json: Optional[_models.QueueCreateOrUpdateParameters] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_name: str, queue_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', "2015-08-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: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, "str", max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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') + _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, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - namespace_name: str, - queue_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, queue_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, "str", max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_get_request( - resource_group_name: str, - namespace_name: str, - queue_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, queue_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', "2015-08-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, "str", max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_authorization_rules_request( - resource_group_name: str, - namespace_name: str, - queue_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, queue_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', "2015-08-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, "str", max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_authorization_rule_request( @@ -227,47 +213,43 @@ def build_create_or_update_authorization_rule_request( queue_name: str, authorization_rule_name: str, subscription_id: str, - *, - json: Optional[_models.SharedAccessAuthorizationRuleCreateOrUpdateParameters] = None, - content: Any = 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', "2015-08-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: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', max_length=50, min_length=1), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, "str", max_length=50, min_length=1), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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') + _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, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_post_authorization_rule_request( @@ -281,34 +263,35 @@ def build_post_authorization_rule_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', max_length=50, min_length=1), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, "str", max_length=50, min_length=1), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_authorization_rule_request( @@ -321,28 +304,30 @@ def build_delete_authorization_rule_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', max_length=50, min_length=1), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, "str", max_length=50, min_length=1), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_get_authorization_rule_request( @@ -356,34 +341,35 @@ def build_get_authorization_rule_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', max_length=50, min_length=1), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, "str", max_length=50, min_length=1), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_keys_request( @@ -397,34 +383,35 @@ def build_list_keys_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/ListKeys") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/ListKeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', max_length=50, min_length=1), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, "str", max_length=50, min_length=1), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_regenerate_keys_request( @@ -433,47 +420,44 @@ def build_regenerate_keys_request( queue_name: str, authorization_rule_name: str, subscription_id: str, - *, - json: Optional[_models.RegenerateKeysParameters] = None, - content: Any = 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', "2015-08-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: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/regenerateKeys") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/regenerateKeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', max_length=50, min_length=1), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, "str", max_length=50, min_length=1), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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, - 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 QueuesOperations: """ @@ -494,63 +478,65 @@ def __init__(self, *args, **kwargs): 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_all( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> Iterable[_models.QueueListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> Iterable["_models.QueueResource"]: """Gets the queues within a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either QueueListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2015_08_01.models.QueueListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either QueueResource or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2015_08_01.models.QueueResource] + :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', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.QueueListResult] + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + cls: ClsType[_models.QueueListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_all_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_all.metadata['url'], + template_url=self.list_all.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_all_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -558,16 +544,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("QueueListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -577,49 +561,122 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_all.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues"} # type: ignore + list_all.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues" + } - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, namespace_name: str, queue_name: str, parameters: _models.QueueCreateOrUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.QueueResource: """Creates or updates a Service Bus queue. This operation is idempotent. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param parameters: Parameters supplied to create or update a queue resource. + :param parameters: Parameters supplied to create or update a queue resource. Required. :type parameters: ~azure.mgmt.servicebus.v2015_08_01.models.QueueCreateOrUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: QueueResource, or the result of cls(response) + :return: QueueResource or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.QueueResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.QueueResource: + """Creates or updates a Service Bus queue. This operation is idempotent. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param parameters: Parameters supplied to create or update a queue resource. Required. + :type 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: QueueResource or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.QueueResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + parameters: Union[_models.QueueCreateOrUpdateParameters, IO], + **kwargs: Any + ) -> _models.QueueResource: + """Creates or updates a Service Bus queue. This operation is idempotent. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param parameters: Parameters supplied to create or update a queue resource. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2015_08_01.models.QueueCreateOrUpdateParameters 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: QueueResource or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.QueueResource + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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', "2015-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.QueueResource] + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.QueueResource] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'QueueCreateOrUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "QueueCreateOrUpdateParameters") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -629,85 +686,83 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - 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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # 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) - deserialized = self._deserialize('QueueResource', pipeline_response) + deserialized = self._deserialize("QueueResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}"} # type: ignore - + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}" + } @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - queue_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, queue_name: str, **kwargs: Any ) -> None: """Deletes a queue from the specified namespace in a resource group. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, queue_name=queue_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -717,139 +772,139 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}"} # type: ignore - + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}" + } @distributed_trace def get( - self, - resource_group_name: str, - namespace_name: str, - queue_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, queue_name: str, **kwargs: Any ) -> _models.QueueResource: """Returns a description for the specified queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: QueueResource, or the result of cls(response) + :return: QueueResource or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.QueueResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.QueueResource] + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + cls: ClsType[_models.QueueResource] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, queue_name=queue_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # 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) - deserialized = self._deserialize('QueueResource', pipeline_response) + deserialized = self._deserialize("QueueResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}" + } @distributed_trace def list_authorization_rules( - self, - resource_group_name: str, - namespace_name: str, - queue_name: str, - **kwargs: Any - ) -> Iterable[_models.SharedAccessAuthorizationRuleListResult]: + self, resource_group_name: str, namespace_name: str, queue_name: str, **kwargs: Any + ) -> Iterable["_models.SharedAccessAuthorizationRuleResource"]: """Gets all authorization rules for a queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SharedAccessAuthorizationRuleListResult or the + :return: An iterator like instance of either SharedAccessAuthorizationRuleResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleResource] + :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', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SharedAccessAuthorizationRuleListResult] + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + cls: ClsType[_models.SharedAccessAuthorizationRuleListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_authorization_rules_request( resource_group_name=resource_group_name, namespace_name=namespace_name, queue_name=queue_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_authorization_rules.metadata['url'], + template_url=self.list_authorization_rules.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_authorization_rules_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - queue_name=queue_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -857,16 +912,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("SharedAccessAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -876,13 +929,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_authorization_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules"} # type: ignore + list_authorization_rules.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules" + } - @distributed_trace + @overload def create_or_update_authorization_rule( self, resource_group_name: str, @@ -890,39 +943,120 @@ def create_or_update_authorization_rule( queue_name: str, authorization_rule_name: str, parameters: _models.SharedAccessAuthorizationRuleCreateOrUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SharedAccessAuthorizationRuleResource: + """Creates an authorization rule for a queue. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Required. + :type parameters: + ~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleCreateOrUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SharedAccessAuthorizationRuleResource or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SharedAccessAuthorizationRuleResource: """Creates an authorization rule for a queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: The shared access authorization rule. + :param parameters: The shared access authorization rule. Required. + :type 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: SharedAccessAuthorizationRuleResource or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: Union[_models.SharedAccessAuthorizationRuleCreateOrUpdateParameters, IO], + **kwargs: Any + ) -> _models.SharedAccessAuthorizationRuleResource: + """Creates an authorization rule for a queue. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Is either a model type or a IO type. + Required. :type parameters: ~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleCreateOrUpdateParameters + 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: SharedAccessAuthorizationRuleResource, or the result of cls(response) + :return: SharedAccessAuthorizationRuleResource or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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', "2015-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SharedAccessAuthorizationRuleResource] + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SharedAccessAuthorizationRuleResource] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'SharedAccessAuthorizationRuleCreateOrUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SharedAccessAuthorizationRuleCreateOrUpdateParameters") request = build_create_or_update_authorization_rule_request( resource_group_name=resource_group_name, @@ -933,33 +1067,34 @@ def create_or_update_authorization_rule( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_authorization_rule.metadata['url'], + content=_content, + template_url=self.create_or_update_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # 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) - deserialized = self._deserialize('SharedAccessAuthorizationRuleResource', pipeline_response) + deserialized = self._deserialize("SharedAccessAuthorizationRuleResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}"} # type: ignore - + create_or_update_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}" + } @distributed_trace def post_authorization_rule( @@ -972,31 +1107,33 @@ def post_authorization_rule( ) -> _models.SharedAccessAuthorizationRuleResource: """Gets an authorization rule for a queue by rule name. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SharedAccessAuthorizationRuleResource, or the result of cls(response) + :return: SharedAccessAuthorizationRuleResource or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SharedAccessAuthorizationRuleResource] + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + cls: ClsType[_models.SharedAccessAuthorizationRuleResource] = kwargs.pop("cls", None) - request = build_post_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -1004,33 +1141,33 @@ def post_authorization_rule( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.post_authorization_rule.metadata['url'], + template_url=self.post_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # 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) - deserialized = self._deserialize('SharedAccessAuthorizationRuleResource', pipeline_response) + deserialized = self._deserialize("SharedAccessAuthorizationRuleResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - post_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}"} # type: ignore - + post_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}" + } @distributed_trace def delete_authorization_rule( # pylint: disable=inconsistent-return-statements @@ -1043,31 +1180,33 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements ) -> None: """Deletes a queue authorization rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -1075,18 +1214,17 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_authorization_rule.metadata['url'], + template_url=self.delete_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1096,8 +1234,9 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}"} # type: ignore - + delete_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}" + } @distributed_trace def get_authorization_rule( @@ -1110,31 +1249,33 @@ def get_authorization_rule( ) -> _models.SharedAccessAuthorizationRuleResource: """Gets an authorization rule for a queue by rule name. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SharedAccessAuthorizationRuleResource, or the result of cls(response) + :return: SharedAccessAuthorizationRuleResource or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SharedAccessAuthorizationRuleResource] + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + cls: ClsType[_models.SharedAccessAuthorizationRuleResource] = kwargs.pop("cls", None) - request = build_get_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -1142,33 +1283,33 @@ def get_authorization_rule( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_authorization_rule.metadata['url'], + template_url=self.get_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # 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) - deserialized = self._deserialize('SharedAccessAuthorizationRuleResource', pipeline_response) + deserialized = self._deserialize("SharedAccessAuthorizationRuleResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}"} # type: ignore - + get_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}" + } @distributed_trace def list_keys( @@ -1181,31 +1322,33 @@ def list_keys( ) -> _models.ResourceListKeys: """Primary and secondary connection strings to the queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceListKeys, or the result of cls(response) + :return: ResourceListKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.ResourceListKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ResourceListKeys] + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + cls: ClsType[_models.ResourceListKeys] = kwargs.pop("cls", None) - request = build_list_keys_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -1213,35 +1356,35 @@ def list_keys( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata['url'], + 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 + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # 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) - deserialized = self._deserialize('ResourceListKeys', pipeline_response) + deserialized = self._deserialize("ResourceListKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/ListKeys"} # type: ignore - + list_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/ListKeys" + } - @distributed_trace + @overload def regenerate_keys( self, resource_group_name: str, @@ -1249,38 +1392,117 @@ def regenerate_keys( queue_name: str, authorization_rule_name: str, parameters: _models.RegenerateKeysParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ResourceListKeys: """Regenerates the primary or secondary connection strings to the queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate the authorization rule. + :param parameters: Parameters supplied to regenerate the authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2015_08_01.models.RegenerateKeysParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceListKeys, or the result of cls(response) + :return: ResourceListKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.ResourceListKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ResourceListKeys: + """Regenerates the primary or secondary connection strings to the queue. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Required. + :type 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: ResourceListKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.ResourceListKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: Union[_models.RegenerateKeysParameters, IO], + **kwargs: Any + ) -> _models.ResourceListKeys: + """Regenerates the primary or secondary connection strings to the queue. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2015_08_01.models.RegenerateKeysParameters 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: ResourceListKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.ResourceListKeys + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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', "2015-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ResourceListKeys] + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ResourceListKeys] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'RegenerateKeysParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RegenerateKeysParameters") request = build_regenerate_keys_request( resource_group_name=resource_group_name, @@ -1291,30 +1513,31 @@ def regenerate_keys( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_keys.metadata['url'], + content=_content, + template_url=self.regenerate_keys.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # 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) - deserialized = self._deserialize('ResourceListKeys', pipeline_response) + deserialized = self._deserialize("ResourceListKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/regenerateKeys"} # type: ignore - + regenerate_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/regenerateKeys" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/operations/_subscriptions_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/operations/_subscriptions_operations.py index d4663e9a9beb4..806905211f5c9 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/operations/_subscriptions_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/operations/_subscriptions_operations.py @@ -6,11 +6,18 @@ # 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 msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,50 +27,52 @@ 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') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_all_request( - resource_group_name: str, - namespace_name: str, - topic_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, topic_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', "2015-08-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( @@ -72,47 +81,41 @@ def build_create_or_update_request( topic_name: str, subscription_name: str, subscription_id: str, - *, - json: Optional[_models.SubscriptionCreateOrUpdateParameters] = None, - content: Any = 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', "2015-08-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: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', max_length=50, min_length=1), - "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", max_length=50, min_length=1), + "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, "str", max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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') + _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, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( @@ -125,28 +128,28 @@ def build_delete_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', max_length=50, min_length=1), - "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", max_length=50, min_length=1), + "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, "str", max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_get_request( @@ -160,34 +163,34 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', max_length=50, min_length=1), - "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", max_length=50, min_length=1), + "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, "str", max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class SubscriptionsOperations: """ @@ -208,70 +211,70 @@ def __init__(self, *args, **kwargs): 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_all( - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - **kwargs: Any - ) -> Iterable[_models.SubscriptionListResult]: + self, resource_group_name: str, namespace_name: str, topic_name: str, **kwargs: Any + ) -> Iterable["_models.SubscriptionResource"]: """List all the subscriptions under a specified topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SubscriptionListResult or the result of + :return: An iterator like instance of either SubscriptionResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2015_08_01.models.SubscriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2015_08_01.models.SubscriptionResource] + :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', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SubscriptionListResult] + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + cls: ClsType[_models.SubscriptionListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_all_request( resource_group_name=resource_group_name, namespace_name=namespace_name, topic_name=topic_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_all.metadata['url'], + template_url=self.list_all.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_all_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - topic_name=topic_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -279,16 +282,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("SubscriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -298,13 +299,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_all.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions"} # type: ignore + list_all.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions" + } - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, @@ -312,39 +313,119 @@ def create_or_update( topic_name: str, subscription_name: str, parameters: _models.SubscriptionCreateOrUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SubscriptionResource: """Creates a topic subscription. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str - :param parameters: Parameters supplied to create a subscription resource. + :param parameters: Parameters supplied to create a subscription resource. Required. :type parameters: ~azure.mgmt.servicebus.v2015_08_01.models.SubscriptionCreateOrUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SubscriptionResource, or the result of cls(response) + :return: SubscriptionResource or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.SubscriptionResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SubscriptionResource: + """Creates a topic subscription. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param parameters: Parameters supplied to create a subscription resource. Required. + :type 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: SubscriptionResource or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.SubscriptionResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + parameters: Union[_models.SubscriptionCreateOrUpdateParameters, IO], + **kwargs: Any + ) -> _models.SubscriptionResource: + """Creates a topic subscription. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param parameters: Parameters supplied to create a subscription resource. Is either a model + type or a IO type. Required. + :type parameters: + ~azure.mgmt.servicebus.v2015_08_01.models.SubscriptionCreateOrUpdateParameters 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: SubscriptionResource or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.SubscriptionResource + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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', "2015-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SubscriptionResource] + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SubscriptionResource] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'SubscriptionCreateOrUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SubscriptionCreateOrUpdateParameters") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -355,70 +436,68 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - 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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # 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) - deserialized = self._deserialize('SubscriptionResource', pipeline_response) + deserialized = self._deserialize("SubscriptionResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}"} # type: ignore - + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}" + } @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - subscription_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, topic_name: str, subscription_name: str, **kwargs: Any ) -> None: """Deletes a subscription from the specified topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -426,18 +505,17 @@ def delete( # pylint: disable=inconsistent-return-statements subscription_name=subscription_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -447,45 +525,43 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}"} # type: ignore - + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}" + } @distributed_trace def get( - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - subscription_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, topic_name: str, subscription_name: str, **kwargs: Any ) -> _models.SubscriptionResource: """Returns a subscription description for the specified topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SubscriptionResource, or the result of cls(response) + :return: SubscriptionResource or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.SubscriptionResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SubscriptionResource] + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + cls: ClsType[_models.SubscriptionResource] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -493,30 +569,30 @@ def get( subscription_name=subscription_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # 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) - deserialized = self._deserialize('SubscriptionResource', pipeline_response) + deserialized = self._deserialize("SubscriptionResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/operations/_topics_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/operations/_topics_operations.py index 12313316a6e4f..ae99e517fcbb4 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/operations/_topics_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/operations/_topics_operations.py @@ -6,11 +6,18 @@ # 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 msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,205 +27,184 @@ 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') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_all_request( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_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', "2015-08-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( - resource_group_name: str, - namespace_name: str, - topic_name: str, - subscription_id: str, - *, - json: Optional[_models.TopicCreateOrUpdateParameters] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_name: str, topic_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', "2015-08-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: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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') + _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, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - namespace_name: str, - topic_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, topic_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_get_request( - resource_group_name: str, - namespace_name: str, - topic_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, topic_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', "2015-08-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_authorization_rules_request( - resource_group_name: str, - namespace_name: str, - topic_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, topic_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', "2015-08-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_authorization_rule_request( @@ -227,47 +213,43 @@ def build_create_or_update_authorization_rule_request( topic_name: str, authorization_rule_name: str, subscription_id: str, - *, - json: Optional[_models.SharedAccessAuthorizationRuleCreateOrUpdateParameters] = None, - content: Any = 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', "2015-08-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: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', max_length=50, min_length=1), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", max_length=50, min_length=1), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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') + _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, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_post_authorization_rule_request( @@ -281,34 +263,35 @@ def build_post_authorization_rule_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', max_length=50, min_length=1), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", max_length=50, min_length=1), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_get_authorization_rule_request( @@ -322,34 +305,35 @@ def build_get_authorization_rule_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', max_length=50, min_length=1), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", max_length=50, min_length=1), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_authorization_rule_request( @@ -362,28 +346,30 @@ def build_delete_authorization_rule_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', max_length=50, min_length=1), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", max_length=50, min_length=1), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_list_keys_request( @@ -397,34 +383,35 @@ def build_list_keys_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/ListKeys") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/ListKeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', max_length=50, min_length=1), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", max_length=50, min_length=1), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_regenerate_keys_request( @@ -433,47 +420,44 @@ def build_regenerate_keys_request( topic_name: str, authorization_rule_name: str, subscription_id: str, - *, - json: Optional[_models.RegenerateKeysParameters] = None, - content: Any = 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', "2015-08-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: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/regenerateKeys") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/regenerateKeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', max_length=50, min_length=1), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", max_length=50, min_length=1), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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, - 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 TopicsOperations: """ @@ -494,63 +478,65 @@ def __init__(self, *args, **kwargs): 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_all( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> Iterable[_models.TopicListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> Iterable["_models.TopicResource"]: """Gets all the topics in a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TopicListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2015_08_01.models.TopicListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either TopicResource or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2015_08_01.models.TopicResource] + :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', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.TopicListResult] + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + cls: ClsType[_models.TopicListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_all_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_all.metadata['url'], + template_url=self.list_all.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_all_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -558,16 +544,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("TopicListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -577,49 +561,122 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_all.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics"} # type: ignore + list_all.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics" + } - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, namespace_name: str, topic_name: str, parameters: _models.TopicCreateOrUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.TopicResource: """Creates a topic in the specified namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param parameters: Parameters supplied to create a topic resource. + :param parameters: Parameters supplied to create a topic resource. Required. :type parameters: ~azure.mgmt.servicebus.v2015_08_01.models.TopicCreateOrUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TopicResource, or the result of cls(response) + :return: TopicResource or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.TopicResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TopicResource: + """Creates a topic in the specified namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param parameters: Parameters supplied to create a topic resource. Required. + :type 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: TopicResource or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.TopicResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + parameters: Union[_models.TopicCreateOrUpdateParameters, IO], + **kwargs: Any + ) -> _models.TopicResource: + """Creates a topic in the specified namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param parameters: Parameters supplied to create a topic resource. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2015_08_01.models.TopicCreateOrUpdateParameters 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: TopicResource or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.TopicResource + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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', "2015-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.TopicResource] + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.TopicResource] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'TopicCreateOrUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TopicCreateOrUpdateParameters") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -629,85 +686,83 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - 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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # 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) - deserialized = self._deserialize('TopicResource', pipeline_response) + deserialized = self._deserialize("TopicResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}"} # type: ignore - + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}" + } @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, topic_name: str, **kwargs: Any ) -> None: """Deletes a topic from the specified namespace and resource group. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, topic_name=topic_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -717,139 +772,139 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}"} # type: ignore - + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}" + } @distributed_trace def get( - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, topic_name: str, **kwargs: Any ) -> _models.TopicResource: """Returns a description for the specified topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TopicResource, or the result of cls(response) + :return: TopicResource or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.TopicResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.TopicResource] + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + cls: ClsType[_models.TopicResource] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, topic_name=topic_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # 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) - deserialized = self._deserialize('TopicResource', pipeline_response) + deserialized = self._deserialize("TopicResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}" + } @distributed_trace def list_authorization_rules( - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - **kwargs: Any - ) -> Iterable[_models.SharedAccessAuthorizationRuleListResult]: + self, resource_group_name: str, namespace_name: str, topic_name: str, **kwargs: Any + ) -> Iterable["_models.SharedAccessAuthorizationRuleResource"]: """Gets authorization rules for a topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SharedAccessAuthorizationRuleListResult or the + :return: An iterator like instance of either SharedAccessAuthorizationRuleResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleResource] + :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', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SharedAccessAuthorizationRuleListResult] + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + cls: ClsType[_models.SharedAccessAuthorizationRuleListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_authorization_rules_request( resource_group_name=resource_group_name, namespace_name=namespace_name, topic_name=topic_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_authorization_rules.metadata['url'], + template_url=self.list_authorization_rules.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_authorization_rules_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - topic_name=topic_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -857,16 +912,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("SharedAccessAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -876,13 +929,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_authorization_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules"} # type: ignore + list_authorization_rules.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules" + } - @distributed_trace + @overload def create_or_update_authorization_rule( self, resource_group_name: str, @@ -890,39 +943,120 @@ def create_or_update_authorization_rule( topic_name: str, authorization_rule_name: str, parameters: _models.SharedAccessAuthorizationRuleCreateOrUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SharedAccessAuthorizationRuleResource: + """Creates an authorization rule for the specified topic. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Required. + :type parameters: + ~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleCreateOrUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SharedAccessAuthorizationRuleResource or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SharedAccessAuthorizationRuleResource: """Creates an authorization rule for the specified topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: The shared access authorization rule. + :param parameters: The shared access authorization rule. Required. + :type 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: SharedAccessAuthorizationRuleResource or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: Union[_models.SharedAccessAuthorizationRuleCreateOrUpdateParameters, IO], + **kwargs: Any + ) -> _models.SharedAccessAuthorizationRuleResource: + """Creates an authorization rule for the specified topic. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Is either a model type or a IO type. + Required. :type parameters: ~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleCreateOrUpdateParameters + 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: SharedAccessAuthorizationRuleResource, or the result of cls(response) + :return: SharedAccessAuthorizationRuleResource or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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', "2015-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SharedAccessAuthorizationRuleResource] + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SharedAccessAuthorizationRuleResource] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'SharedAccessAuthorizationRuleCreateOrUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SharedAccessAuthorizationRuleCreateOrUpdateParameters") request = build_create_or_update_authorization_rule_request( resource_group_name=resource_group_name, @@ -933,33 +1067,34 @@ def create_or_update_authorization_rule( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_authorization_rule.metadata['url'], + content=_content, + template_url=self.create_or_update_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # 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) - deserialized = self._deserialize('SharedAccessAuthorizationRuleResource', pipeline_response) + deserialized = self._deserialize("SharedAccessAuthorizationRuleResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}"} # type: ignore - + create_or_update_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}" + } @distributed_trace def post_authorization_rule( @@ -972,31 +1107,33 @@ def post_authorization_rule( ) -> _models.SharedAccessAuthorizationRuleResource: """Returns the specified authorization rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SharedAccessAuthorizationRuleResource, or the result of cls(response) + :return: SharedAccessAuthorizationRuleResource or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SharedAccessAuthorizationRuleResource] + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + cls: ClsType[_models.SharedAccessAuthorizationRuleResource] = kwargs.pop("cls", None) - request = build_post_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -1004,33 +1141,33 @@ def post_authorization_rule( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.post_authorization_rule.metadata['url'], + template_url=self.post_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # 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) - deserialized = self._deserialize('SharedAccessAuthorizationRuleResource', pipeline_response) + deserialized = self._deserialize("SharedAccessAuthorizationRuleResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - post_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}"} # type: ignore - + post_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}" + } @distributed_trace def get_authorization_rule( @@ -1043,31 +1180,33 @@ def get_authorization_rule( ) -> _models.SharedAccessAuthorizationRuleResource: """Returns the specified authorization rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SharedAccessAuthorizationRuleResource, or the result of cls(response) + :return: SharedAccessAuthorizationRuleResource or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SharedAccessAuthorizationRuleResource] + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + cls: ClsType[_models.SharedAccessAuthorizationRuleResource] = kwargs.pop("cls", None) - request = build_get_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -1075,33 +1214,33 @@ def get_authorization_rule( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_authorization_rule.metadata['url'], + template_url=self.get_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # 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) - deserialized = self._deserialize('SharedAccessAuthorizationRuleResource', pipeline_response) + deserialized = self._deserialize("SharedAccessAuthorizationRuleResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}"} # type: ignore - + get_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}" + } @distributed_trace def delete_authorization_rule( # pylint: disable=inconsistent-return-statements @@ -1114,31 +1253,33 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements ) -> None: """Deletes a topic authorization rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -1146,18 +1287,17 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_authorization_rule.metadata['url'], + template_url=self.delete_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1167,8 +1307,9 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}"} # type: ignore - + delete_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}" + } @distributed_trace def list_keys( @@ -1181,31 +1322,33 @@ def list_keys( ) -> _models.ResourceListKeys: """Gets the primary and secondary connection strings for the topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceListKeys, or the result of cls(response) + :return: ResourceListKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.ResourceListKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ResourceListKeys] + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + cls: ClsType[_models.ResourceListKeys] = kwargs.pop("cls", None) - request = build_list_keys_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -1213,35 +1356,35 @@ def list_keys( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata['url'], + 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 + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # 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) - deserialized = self._deserialize('ResourceListKeys', pipeline_response) + deserialized = self._deserialize("ResourceListKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/ListKeys"} # type: ignore - + list_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/ListKeys" + } - @distributed_trace + @overload def regenerate_keys( self, resource_group_name: str, @@ -1249,38 +1392,117 @@ def regenerate_keys( topic_name: str, authorization_rule_name: str, parameters: _models.RegenerateKeysParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ResourceListKeys: """Regenerates primary or secondary connection strings for the topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate the authorization rule. + :param parameters: Parameters supplied to regenerate the authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2015_08_01.models.RegenerateKeysParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceListKeys, or the result of cls(response) + :return: ResourceListKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.ResourceListKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ResourceListKeys: + """Regenerates primary or secondary connection strings for the topic. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Required. + :type 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: ResourceListKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.ResourceListKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: Union[_models.RegenerateKeysParameters, IO], + **kwargs: Any + ) -> _models.ResourceListKeys: + """Regenerates primary or secondary connection strings for the topic. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2015_08_01.models.RegenerateKeysParameters 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: ResourceListKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.ResourceListKeys + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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', "2015-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ResourceListKeys] + api_version: Literal["2015-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ResourceListKeys] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'RegenerateKeysParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RegenerateKeysParameters") request = build_regenerate_keys_request( resource_group_name=resource_group_name, @@ -1291,30 +1513,31 @@ def regenerate_keys( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_keys.metadata['url'], + content=_content, + template_url=self.regenerate_keys.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # 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) - deserialized = self._deserialize('ResourceListKeys', pipeline_response) + deserialized = self._deserialize("ResourceListKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/regenerateKeys"} # type: ignore - + regenerate_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/regenerateKeys" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/__init__.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/__init__.py index 221541a00fb6e..2e171d69863bf 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/__init__.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/__init__.py @@ -13,11 +13,14 @@ try: from ._patch import __all__ as _patch_all - from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import + from ._patch import * # pylint: disable=unused-wildcard-import except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['ServiceBusManagementClient'] + +__all__ = [ + "ServiceBusManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/_configuration.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/_configuration.py index 9d9d0c72d087a..4e54d8afb8a32 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/_configuration.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from ._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential @@ -25,24 +31,19 @@ class ServiceBusManagementClientConfiguration(Configuration): # pylint: disable 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: Subscription credentials that uniquely identify a Microsoft Azure - subscription. The subscription ID forms part of the URI for every service call. + subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2017-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(ServiceBusManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2017-04-01") # type: str + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", "2017-04-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -52,23 +53,21 @@ def __init__( 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-servicebus/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-servicebus/{}".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') + 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.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/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/_metadata.json b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/_metadata.json index d03a673a307ff..69e3193ba7625 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/_metadata.json +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_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\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ServiceBusManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"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\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ServiceBusManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"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\": [\"ServiceBusManagementClientConfiguration\"], \".._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\": [\"ServiceBusManagementClientConfiguration\"], \"..._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": "Subscription credentials that uniquely identify a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.", + "signature": "subscription_id: str,", + "description": "Subscription credentials that uniquely identify a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. 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": "Subscription credentials that uniquely identify a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.", + "description": "Subscription credentials that uniquely identify a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. Required.", "docstring_type": "str", "required": true } @@ -48,19 +48,19 @@ "service_client_specific": { "sync": { "api_version": { - "signature": "api_version=None, # type: Optional[str]", + "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=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false }, "profile": { - "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "signature": "profile: KnownProfiles=KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", "required": false @@ -109,4 +109,4 @@ "regions": "RegionsOperations", "subscriptions": "SubscriptionsOperations" } -} \ No newline at end of file +} diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/_patch.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/_patch.py index 0ad201a8c586e..f7dd32510333d 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/_patch.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/_service_bus_management_client.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/_service_bus_management_client.py index 249f40ddf4673..8efb3b52496a3 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/_service_bus_management_client.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/_service_bus_management_client.py @@ -9,20 +9,32 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from . import models +from . import models as _models +from .._serialization import Deserializer, Serializer from ._configuration import ServiceBusManagementClientConfiguration -from .operations import DisasterRecoveryConfigsOperations, EventHubsOperations, MigrationConfigsOperations, NamespacesOperations, Operations, PremiumMessagingRegionsOperations, QueuesOperations, RegionsOperations, RulesOperations, SubscriptionsOperations, TopicsOperations +from .operations import ( + DisasterRecoveryConfigsOperations, + EventHubsOperations, + MigrationConfigsOperations, + NamespacesOperations, + Operations, + PremiumMessagingRegionsOperations, + QueuesOperations, + RegionsOperations, + RulesOperations, + SubscriptionsOperations, + TopicsOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class ServiceBusManagementClient: # pylint: disable=too-many-instance-attributes + +class ServiceBusManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Azure Service Bus client. :ivar namespaces: NamespacesOperations operations @@ -50,10 +62,10 @@ class ServiceBusManagementClient: # pylint: disable=too-many-instance-attribu :vartype regions: azure.mgmt.servicebus.v2017_04_01.operations.RegionsOperations :ivar subscriptions: SubscriptionsOperations operations :vartype subscriptions: azure.mgmt.servicebus.v2017_04_01.operations.SubscriptionsOperations - :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: Subscription credentials that uniquely identify a Microsoft Azure - subscription. The subscription ID forms part of the URI for every service call. + subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -71,53 +83,34 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = ServiceBusManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = ServiceBusManagementClientConfiguration( + 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)} + 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.namespaces = NamespacesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.queues = QueuesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.topics = TopicsOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.namespaces = NamespacesOperations(self._client, self._config, self._serialize, self._deserialize) + self.queues = QueuesOperations(self._client, self._config, self._serialize, self._deserialize) + self.topics = TopicsOperations(self._client, self._config, self._serialize, self._deserialize) self.disaster_recovery_configs = DisasterRecoveryConfigsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.event_hubs = EventHubsOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.event_hubs = EventHubsOperations(self._client, self._config, self._serialize, self._deserialize) self.migration_configs = MigrationConfigsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize - ) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) self.premium_messaging_regions = PremiumMessagingRegionsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.rules = RulesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.regions = RegionsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.subscriptions = SubscriptionsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - + self.rules = RulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.regions = RegionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.subscriptions = SubscriptionsOperations(self._client, self._config, self._serialize, self._deserialize) - def _send_request( - self, - request: 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 @@ -126,7 +119,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 @@ -139,15 +132,12 @@ def _send_request( request_copy.url = self._client.format_url(request_copy.url) return self._client.send_request(request_copy, **kwargs) - def close(self): - # type: () -> None + def close(self) -> None: self._client.close() - def __enter__(self): - # type: () -> ServiceBusManagementClient + def __enter__(self) -> "ServiceBusManagementClient": self._client.__enter__() return self - def __exit__(self, *exc_details): - # type: (Any) -> None + def __exit__(self, *exc_details) -> None: self._client.__exit__(*exc_details) diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/_vendor.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/_vendor.py index 138f663c53a4e..9aad73fc743e7 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/_vendor.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_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/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/_version.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/_version.py index 920456322fa12..e5754a47ce68f 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/_version.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "8.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/__init__.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/__init__.py index e7dd87df1f939..530b8638dfd32 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/__init__.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/__init__.py @@ -10,11 +10,14 @@ try: from ._patch import __all__ as _patch_all - from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import + from ._patch import * # pylint: disable=unused-wildcard-import except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['ServiceBusManagementClient'] + +__all__ = [ + "ServiceBusManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/_configuration.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/_configuration.py index 866336bb09598..9e93f841b2de0 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/_configuration.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from .._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential @@ -25,24 +31,19 @@ class ServiceBusManagementClientConfiguration(Configuration): # pylint: disable 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: Subscription credentials that uniquely identify a Microsoft Azure - subscription. The subscription ID forms part of the URI for every service call. + subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2017-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(ServiceBusManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2017-04-01") # type: str + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", "2017-04-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -52,22 +53,21 @@ def __init__( 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-servicebus/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-servicebus/{}".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/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/_patch.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/_patch.py index 0ad201a8c586e..f7dd32510333d 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/_patch.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/_service_bus_management_client.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/_service_bus_management_client.py index 749cedf823ea9..bbb70436b3f83 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/_service_bus_management_client.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/_service_bus_management_client.py @@ -9,20 +9,32 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from .. import models +from .. import models as _models +from ..._serialization import Deserializer, Serializer from ._configuration import ServiceBusManagementClientConfiguration -from .operations import DisasterRecoveryConfigsOperations, EventHubsOperations, MigrationConfigsOperations, NamespacesOperations, Operations, PremiumMessagingRegionsOperations, QueuesOperations, RegionsOperations, RulesOperations, SubscriptionsOperations, TopicsOperations +from .operations import ( + DisasterRecoveryConfigsOperations, + EventHubsOperations, + MigrationConfigsOperations, + NamespacesOperations, + Operations, + PremiumMessagingRegionsOperations, + QueuesOperations, + RegionsOperations, + RulesOperations, + SubscriptionsOperations, + TopicsOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class ServiceBusManagementClient: # pylint: disable=too-many-instance-attributes + +class ServiceBusManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Azure Service Bus client. :ivar namespaces: NamespacesOperations operations @@ -51,10 +63,10 @@ class ServiceBusManagementClient: # pylint: disable=too-many-instance-attribu :ivar subscriptions: SubscriptionsOperations operations :vartype subscriptions: azure.mgmt.servicebus.v2017_04_01.aio.operations.SubscriptionsOperations - :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: Subscription credentials that uniquely identify a Microsoft Azure - subscription. The subscription ID forms part of the URI for every service call. + subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -72,53 +84,34 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = ServiceBusManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = ServiceBusManagementClientConfiguration( + 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)} + 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.namespaces = NamespacesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.queues = QueuesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.topics = TopicsOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.namespaces = NamespacesOperations(self._client, self._config, self._serialize, self._deserialize) + self.queues = QueuesOperations(self._client, self._config, self._serialize, self._deserialize) + self.topics = TopicsOperations(self._client, self._config, self._serialize, self._deserialize) self.disaster_recovery_configs = DisasterRecoveryConfigsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.event_hubs = EventHubsOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.event_hubs = EventHubsOperations(self._client, self._config, self._serialize, self._deserialize) self.migration_configs = MigrationConfigsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize - ) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) self.premium_messaging_regions = PremiumMessagingRegionsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.rules = RulesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.regions = RegionsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.subscriptions = SubscriptionsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - + self.rules = RulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.regions = RegionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.subscriptions = SubscriptionsOperations(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 @@ -127,7 +120,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/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/__init__.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/__init__.py index 02badefef72e4..dbb5c8284b01c 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/__init__.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/__init__.py @@ -19,20 +19,21 @@ from ._subscriptions_operations import SubscriptionsOperations from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'NamespacesOperations', - 'QueuesOperations', - 'TopicsOperations', - 'DisasterRecoveryConfigsOperations', - 'EventHubsOperations', - 'MigrationConfigsOperations', - 'Operations', - 'PremiumMessagingRegionsOperations', - 'RulesOperations', - 'RegionsOperations', - 'SubscriptionsOperations', + "NamespacesOperations", + "QueuesOperations", + "TopicsOperations", + "DisasterRecoveryConfigsOperations", + "EventHubsOperations", + "MigrationConfigsOperations", + "Operations", + "PremiumMessagingRegionsOperations", + "RulesOperations", + "RegionsOperations", + "SubscriptionsOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/_disaster_recovery_configs_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/_disaster_recovery_configs_operations.py index 743016e9ff7de..8716351acafcf 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/_disaster_recovery_configs_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/_disaster_recovery_configs_operations.py @@ -6,10 +6,19 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,27 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._disaster_recovery_configs_operations import build_break_pairing_request, build_check_name_availability_request, build_create_or_update_request, build_delete_request, build_fail_over_request, build_get_authorization_rule_request, build_get_request, build_list_authorization_rules_request, build_list_keys_request, build_list_request -T = TypeVar('T') +from ...operations._disaster_recovery_configs_operations import ( + build_break_pairing_request, + build_check_name_availability_request, + build_create_or_update_request, + build_delete_request, + build_fail_over_request, + build_get_authorization_rule_request, + build_get_request, + build_list_authorization_rules_request, + build_list_keys_request, + build_list_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class DisasterRecoveryConfigsOperations: """ .. warning:: @@ -43,41 +69,107 @@ def __init__(self, *args, **kwargs) -> None: 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 + @overload async def check_name_availability( self, resource_group_name: str, namespace_name: str, parameters: _models.CheckNameAvailability, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Check the give namespace name availability. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: Parameters to check availability of the given namespace name. + :param parameters: Parameters to check availability of the given namespace name. Required. :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.CheckNameAvailability + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckNameAvailabilityResult, or the result of cls(response) + :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.CheckNameAvailabilityResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters to check availability of the given namespace name. Required. + :type 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: CheckNameAvailabilityResult or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_name_availability( + self, + resource_group_name: str, + namespace_name: str, + parameters: Union[_models.CheckNameAvailability, IO], + **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters to check availability of the given namespace name. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.CheckNameAvailability 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: CheckNameAvailabilityResult or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.CheckNameAvailabilityResult] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CheckNameAvailabilityResult] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'CheckNameAvailability') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "CheckNameAvailability") request = build_check_name_availability_request( resource_group_name=resource_group_name, @@ -86,18 +178,18 @@ async def check_name_availability( 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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -105,74 +197,77 @@ async def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) + deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/CheckNameAvailability"} # type: ignore - + check_name_availability.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/CheckNameAvailability" + } @distributed_trace def list( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.ArmDisasterRecoveryListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ArmDisasterRecovery"]: """Gets all Alias(Disaster Recovery configurations). - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ArmDisasterRecoveryListResult or the result of - cls(response) + :return: An iterator like instance of either ArmDisasterRecovery or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.ArmDisasterRecoveryListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.ArmDisasterRecovery] + :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', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ArmDisasterRecoveryListResult] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[_models.ArmDisasterRecoveryListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -180,16 +275,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("ArmDisasterRecoveryListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -200,49 +293,124 @@ 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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs" + } - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, namespace_name: str, alias: str, parameters: _models.ArmDisasterRecovery, + *, + content_type: str = "application/json", **kwargs: Any ) -> Optional[_models.ArmDisasterRecovery]: """Creates or updates a new Alias(Disaster Recovery configuration). - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: str :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). + Required. :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.ArmDisasterRecovery + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ArmDisasterRecovery or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.ArmDisasterRecovery or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + alias: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> Optional[_models.ArmDisasterRecovery]: + """Creates or updates a new Alias(Disaster Recovery configuration). + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: str + :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). + Required. + :type 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: ArmDisasterRecovery, or the result of cls(response) + :return: ArmDisasterRecovery or None or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.ArmDisasterRecovery or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + alias: str, + parameters: Union[_models.ArmDisasterRecovery, IO], + **kwargs: Any + ) -> Optional[_models.ArmDisasterRecovery]: + """Creates or updates a new Alias(Disaster Recovery configuration). + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: str + :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). Is + either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.ArmDisasterRecovery 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: ArmDisasterRecovery or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.ArmDisasterRecovery or None + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ArmDisasterRecovery]] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.ArmDisasterRecovery]] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'ArmDisasterRecovery') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ArmDisasterRecovery") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -252,18 +420,18 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - 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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -273,67 +441,65 @@ async def create_or_update( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ArmDisasterRecovery', pipeline_response) + deserialized = self._deserialize("ArmDisasterRecovery", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}"} # type: ignore - + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}" + } @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - alias: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, alias: str, **kwargs: Any ) -> None: """Deletes an Alias(Disaster Recovery configuration). - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: 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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, alias=alias, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -344,60 +510,58 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}"} # type: ignore - + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}" + } @distributed_trace_async async def get( - self, - resource_group_name: str, - namespace_name: str, - alias: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, alias: str, **kwargs: Any ) -> _models.ArmDisasterRecovery: """Retrieves Alias(Disaster Recovery configuration) for primary or secondary namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ArmDisasterRecovery, or the result of cls(response) + :return: ArmDisasterRecovery or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.ArmDisasterRecovery - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ArmDisasterRecovery] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[_models.ArmDisasterRecovery] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, alias=alias, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -405,68 +569,66 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ArmDisasterRecovery', pipeline_response) + deserialized = self._deserialize("ArmDisasterRecovery", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}" + } @distributed_trace_async async def break_pairing( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - alias: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, alias: str, **kwargs: Any ) -> None: """This operation disables the Disaster Recovery and stops replicating changes from primary to secondary namespaces. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: 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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_break_pairing_request( resource_group_name=resource_group_name, namespace_name=namespace_name, alias=alias, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.break_pairing.metadata['url'], + template_url=self.break_pairing.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -477,60 +639,58 @@ async def break_pairing( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - break_pairing.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/breakPairing"} # type: ignore - + break_pairing.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/breakPairing" + } @distributed_trace_async async def fail_over( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - alias: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, alias: str, **kwargs: Any ) -> None: """Invokes GEO DR failover and reconfigure the alias to point to the secondary namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: 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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_fail_over_request( resource_group_name=resource_group_name, namespace_name=namespace_name, alias=alias, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.fail_over.metadata['url'], + template_url=self.fail_over.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -541,72 +701,73 @@ async def fail_over( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - fail_over.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/failover"} # type: ignore - + fail_over.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/failover" + } @distributed_trace def list_authorization_rules( - self, - resource_group_name: str, - namespace_name: str, - alias: str, - **kwargs: Any - ) -> AsyncIterable[_models.SBAuthorizationRuleListResult]: + self, resource_group_name: str, namespace_name: str, alias: str, **kwargs: Any + ) -> AsyncIterable["_models.SBAuthorizationRule"]: """Gets the authorization rules for a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of - cls(response) + :return: An iterator like instance of either SBAuthorizationRule or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRule] + :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', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRuleListResult] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[_models.SBAuthorizationRuleListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_authorization_rules_request( resource_group_name=resource_group_name, namespace_name=namespace_name, alias=alias, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_authorization_rules.metadata['url'], + template_url=self.list_authorization_rules.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_authorization_rules_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - alias=alias, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -614,16 +775,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("SBAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -634,48 +793,45 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_authorization_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/AuthorizationRules"} # type: ignore + list_authorization_rules.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/AuthorizationRules" + } @distributed_trace_async async def get_authorization_rule( - self, - resource_group_name: str, - namespace_name: str, - alias: str, - authorization_rule_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, alias: str, authorization_rule_name: str, **kwargs: Any ) -> _models.SBAuthorizationRule: """Gets an authorization rule for a namespace by rule name. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[_models.SBAuthorizationRule] = kwargs.pop("cls", None) - request = build_get_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -683,18 +839,17 @@ async def get_authorization_rule( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_authorization_rule.metadata['url'], + template_url=self.get_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -702,52 +857,50 @@ async def get_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/AuthorizationRules/{authorizationRuleName}"} # type: ignore - + get_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/AuthorizationRules/{authorizationRuleName}" + } @distributed_trace_async async def list_keys( - self, - resource_group_name: str, - namespace_name: str, - alias: str, - authorization_rule_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, alias: str, authorization_rule_name: str, **kwargs: Any ) -> _models.AccessKeys: """Gets the primary and secondary connection strings for the namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[_models.AccessKeys] = kwargs.pop("cls", None) - request = build_list_keys_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -755,18 +908,17 @@ async def list_keys( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata['url'], + 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 + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -774,12 +926,13 @@ async def list_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + deserialized = self._deserialize("AccessKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/AuthorizationRules/{authorizationRuleName}/listKeys"} # type: ignore - + list_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/AuthorizationRules/{authorizationRuleName}/listKeys" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/_event_hubs_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/_event_hubs_operations.py index 07825d2e1437c..31bfd2435a9ae 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/_event_hubs_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/_event_hubs_operations.py @@ -6,10 +6,19 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +29,15 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._event_hubs_operations import build_list_by_namespace_request -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class EventHubsOperations: """ .. warning:: @@ -42,64 +57,66 @@ def __init__(self, *args, **kwargs) -> None: 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_namespace( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.EventHubListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Eventhub"]: """Gets all the Event Hubs in a service bus Namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventHubListResult or the result of cls(response) + :return: An iterator like instance of either Eventhub or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.EventHubListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.Eventhub] + :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', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.EventHubListResult] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[_models.EventHubListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_namespace_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_namespace.metadata['url'], + template_url=self.list_by_namespace.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_by_namespace_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -107,16 +124,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("EventHubListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -127,8 +142,8 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_namespace.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/eventhubs"} # type: ignore + list_by_namespace.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/eventhubs" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/_migration_configs_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/_migration_configs_operations.py index 83016da8a6d6d..88e7ff8d57ce3 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/_migration_configs_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/_migration_configs_operations.py @@ -6,10 +6,19 @@ # 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, Union, cast +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod @@ -22,10 +31,23 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._migration_configs_operations import build_complete_migration_request, build_create_and_start_migration_request_initial, build_delete_request, build_get_request, build_list_request, build_revert_request -T = TypeVar('T') +from ...operations._migration_configs_operations import ( + build_complete_migration_request, + build_create_and_start_migration_request, + build_delete_request, + build_get_request, + build_list_request, + build_revert_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class MigrationConfigsOperations: """ .. warning:: @@ -45,65 +67,67 @@ def __init__(self, *args, **kwargs) -> None: 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, - namespace_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.MigrationConfigListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> AsyncIterable["_models.MigrationConfigProperties"]: """Gets all migrationConfigurations. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MigrationConfigListResult or the result of + :return: An iterator like instance of either MigrationConfigProperties or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.MigrationConfigListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.MigrationConfigProperties] + :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', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MigrationConfigListResult] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[_models.MigrationConfigListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -111,16 +135,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("MigrationConfigListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -131,35 +153,44 @@ 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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations" + } async def _create_and_start_migration_initial( self, resource_group_name: str, namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], - parameters: _models.MigrationConfigProperties, + config_name: Union[str, _models.MigrationConfigurationName], + parameters: Union[_models.MigrationConfigProperties, IO], **kwargs: Any ) -> Optional[_models.MigrationConfigProperties]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.MigrationConfigProperties]] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.MigrationConfigProperties]] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'MigrationConfigProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "MigrationConfigProperties") - request = build_create_and_start_migration_request_initial( + request = build_create_and_start_migration_request( resource_group_name=resource_group_name, namespace_name=namespace_name, config_name=config_name, @@ -167,56 +198,142 @@ async def _create_and_start_migration_initial( api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_and_start_migration_initial.metadata['url'], + content=_content, + template_url=self._create_and_start_migration_initial.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('MigrationConfigProperties', pipeline_response) + deserialized = self._deserialize("MigrationConfigProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_and_start_migration_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}"} # type: ignore + _create_and_start_migration_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}" + } - - @distributed_trace_async + @overload async def begin_create_and_start_migration( self, resource_group_name: str, namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], + config_name: Union[str, _models.MigrationConfigurationName], parameters: _models.MigrationConfigProperties, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.MigrationConfigProperties]: """Creates Migration configuration and starts migration of entities from Standard to Premium namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :type config_name: str or ~azure.mgmt.servicebus.v2017_04_01.models.MigrationConfigurationName - :param parameters: Parameters required to create Migration Configuration. + :param parameters: Parameters required to create Migration Configuration. Required. :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.MigrationConfigProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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 MigrationConfigProperties or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.servicebus.v2017_04_01.models.MigrationConfigProperties] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_and_start_migration( + self, + resource_group_name: str, + namespace_name: str, + config_name: Union[str, _models.MigrationConfigurationName], + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.MigrationConfigProperties]: + """Creates Migration configuration and starts migration of entities from Standard to Premium + namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param config_name: The configuration name. Should always be "$default". "$default" Required. + :type config_name: str or ~azure.mgmt.servicebus.v2017_04_01.models.MigrationConfigurationName + :param parameters: Parameters required to create Migration Configuration. Required. + :type 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 + :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 MigrationConfigProperties or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.servicebus.v2017_04_01.models.MigrationConfigProperties] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_and_start_migration( + self, + resource_group_name: str, + namespace_name: str, + config_name: Union[str, _models.MigrationConfigurationName], + parameters: Union[_models.MigrationConfigProperties, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.MigrationConfigProperties]: + """Creates Migration configuration and starts migration of entities from Standard to Premium + namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param config_name: The configuration name. Should always be "$default". "$default" Required. + :type config_name: str or ~azure.mgmt.servicebus.v2017_04_01.models.MigrationConfigurationName + :param parameters: Parameters required to create Migration Configuration. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.MigrationConfigProperties 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 @@ -229,113 +346,109 @@ async def begin_create_and_start_migration( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.servicebus.v2017_04_01.models.MigrationConfigProperties] - :raises: ~azure.core.exceptions.HttpResponseError + :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', "2017-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.MigrationConfigProperties] - 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] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.MigrationConfigProperties] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._create_and_start_migration_initial( # type: ignore + raw_result = await self._create_and_start_migration_initial( resource_group_name=resource_group_name, namespace_name=namespace_name, config_name=config_name, parameters=parameters, 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): - deserialized = self._deserialize('MigrationConfigProperties', pipeline_response) + deserialized = self._deserialize("MigrationConfigProperties", 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 + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create_and_start_migration.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}"} # type: ignore + begin_create_and_start_migration.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}" + } @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], + config_name: Union[str, _models.MigrationConfigurationName], **kwargs: Any ) -> None: """Deletes a MigrationConfiguration. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :type config_name: str or ~azure.mgmt.servicebus.v2017_04_01.models.MigrationConfigurationName :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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, config_name=config_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -346,60 +459,62 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}"} # type: ignore - + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}" + } @distributed_trace_async async def get( self, resource_group_name: str, namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], + config_name: Union[str, _models.MigrationConfigurationName], **kwargs: Any ) -> _models.MigrationConfigProperties: """Retrieves Migration Config. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :type config_name: str or ~azure.mgmt.servicebus.v2017_04_01.models.MigrationConfigurationName :keyword callable cls: A custom type or function that will be passed the direct response - :return: MigrationConfigProperties, or the result of cls(response) + :return: MigrationConfigProperties or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.MigrationConfigProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MigrationConfigProperties] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[_models.MigrationConfigProperties] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, config_name=config_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -407,69 +522,71 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('MigrationConfigProperties', pipeline_response) + deserialized = self._deserialize("MigrationConfigProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}" + } @distributed_trace_async async def complete_migration( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], + config_name: Union[str, _models.MigrationConfigurationName], **kwargs: Any ) -> None: """This operation Completes Migration of entities by pointing the connection strings to Premium namespace and any entities created after the operation will be under Premium Namespace. CompleteMigration operation will fail when entity migration is in-progress. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :type config_name: str or ~azure.mgmt.servicebus.v2017_04_01.models.MigrationConfigurationName :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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_complete_migration_request( resource_group_name=resource_group_name, namespace_name=namespace_name, config_name=config_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.complete_migration.metadata['url'], + template_url=self.complete_migration.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -480,60 +597,62 @@ async def complete_migration( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - complete_migration.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/upgrade"} # type: ignore - + complete_migration.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/upgrade" + } @distributed_trace_async async def revert( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], + config_name: Union[str, _models.MigrationConfigurationName], **kwargs: Any ) -> None: """This operation reverts Migration. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :type config_name: str or ~azure.mgmt.servicebus.v2017_04_01.models.MigrationConfigurationName :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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_revert_request( resource_group_name=resource_group_name, namespace_name=namespace_name, config_name=config_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.revert.metadata['url'], + template_url=self.revert.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -544,5 +663,6 @@ async def revert( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - revert.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/revert"} # type: ignore - + revert.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/revert" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/_namespaces_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/_namespaces_operations.py index bb8e82ba64c7f..31b6124a8b39c 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/_namespaces_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/_namespaces_operations.py @@ -6,10 +6,19 @@ # 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, Union, cast +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod @@ -22,10 +31,34 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._namespaces_operations import build_check_name_availability_request, build_create_or_update_authorization_rule_request, build_create_or_update_network_rule_set_request, build_create_or_update_request_initial, build_delete_authorization_rule_request, build_delete_request_initial, build_get_authorization_rule_request, build_get_network_rule_set_request, build_get_request, build_list_authorization_rules_request, build_list_by_resource_group_request, build_list_keys_request, build_list_network_rule_sets_request, build_list_request, build_migrate_request, build_regenerate_keys_request, build_update_request -T = TypeVar('T') +from ...operations._namespaces_operations import ( + build_check_name_availability_request, + build_create_or_update_authorization_rule_request, + build_create_or_update_network_rule_set_request, + build_create_or_update_request, + build_delete_authorization_rule_request, + build_delete_request, + build_get_authorization_rule_request, + build_get_network_rule_set_request, + build_get_request, + build_list_authorization_rules_request, + build_list_by_resource_group_request, + build_list_keys_request, + build_list_network_rule_sets_request, + build_list_request, + build_migrate_request, + build_regenerate_keys_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class NamespacesOperations: """ .. warning:: @@ -45,65 +78,66 @@ def __init__(self, *args, **kwargs) -> None: 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_authorization_rules( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.SBAuthorizationRuleListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> AsyncIterable["_models.SBAuthorizationRule"]: """Gets the authorization rules for a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of - cls(response) + :return: An iterator like instance of either SBAuthorizationRule or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRule] + :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', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRuleListResult] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[_models.SBAuthorizationRuleListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_authorization_rules_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_authorization_rules.metadata['url'], + template_url=self.list_authorization_rules.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_authorization_rules_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -111,16 +145,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("SBAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -131,49 +163,122 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_authorization_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules"} # type: ignore + list_authorization_rules.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules" + } - @distributed_trace_async + @overload async def create_or_update_authorization_rule( self, resource_group_name: str, namespace_name: str, authorization_rule_name: str, parameters: _models.SBAuthorizationRule, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SBAuthorizationRule: """Creates or updates an authorization rule for a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: The shared access authorization rule. + :param parameters: The shared access authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBAuthorizationRule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates or updates an authorization rule for a namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Required. + :type 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: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: Union[_models.SBAuthorizationRule, IO], + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates or updates an authorization rule for a namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRule 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: SBAuthorizationRule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SBAuthorizationRule] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'SBAuthorizationRule') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBAuthorizationRule") request = build_create_or_update_authorization_rule_request( resource_group_name=resource_group_name, @@ -183,18 +288,18 @@ async def create_or_update_authorization_rule( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_authorization_rule.metadata['url'], + content=_content, + template_url=self.create_or_update_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -202,67 +307,65 @@ async def create_or_update_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}"} # type: ignore - + create_or_update_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}" + } @distributed_trace_async async def delete_authorization_rule( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, authorization_rule_name: str, **kwargs: Any ) -> None: """Deletes a namespace authorization rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_authorization_rule.metadata['url'], + template_url=self.delete_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -273,60 +376,58 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat if cls: return cls(pipeline_response, None, {}) - delete_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}"} # type: ignore - + delete_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}" + } @distributed_trace_async async def get_authorization_rule( - self, - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, authorization_rule_name: str, **kwargs: Any ) -> _models.SBAuthorizationRule: """Gets an authorization rule for a namespace by rule name. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[_models.SBAuthorizationRule] = kwargs.pop("cls", None) - request = build_get_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_authorization_rule.metadata['url'], + template_url=self.get_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -334,67 +435,65 @@ async def get_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}"} # type: ignore - + get_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}" + } @distributed_trace_async async def list_keys( - self, - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, authorization_rule_name: str, **kwargs: Any ) -> _models.AccessKeys: """Gets the primary and secondary connection strings for the namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[_models.AccessKeys] = kwargs.pop("cls", None) - request = build_list_keys_request( resource_group_name=resource_group_name, namespace_name=namespace_name, authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata['url'], + 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 + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -402,53 +501,127 @@ async def list_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + deserialized = self._deserialize("AccessKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/listKeys"} # type: ignore + list_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/listKeys" + } - - @distributed_trace_async + @overload async def regenerate_keys( self, resource_group_name: str, namespace_name: str, authorization_rule_name: str, parameters: _models.RegenerateAccessKeyParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.AccessKeys: """Regenerates the primary or secondary connection strings for the namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate the authorization rule. + :param parameters: Parameters supplied to regenerate the authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.RegenerateAccessKeyParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AccessKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AccessKeys: + """Regenerates the primary or secondary connection strings for the namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Required. + :type 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: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: Union[_models.RegenerateAccessKeyParameters, IO], + **kwargs: Any + ) -> _models.AccessKeys: + """Regenerates the primary or secondary connection strings for the namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.RegenerateAccessKeyParameters 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: AccessKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AccessKeys] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RegenerateAccessKeyParameters") request = build_regenerate_keys_request( resource_group_name=resource_group_name, @@ -458,18 +631,18 @@ async def regenerate_keys( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_keys.metadata['url'], + content=_content, + template_url=self.regenerate_keys.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -477,62 +650,108 @@ async def regenerate_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + deserialized = self._deserialize("AccessKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/regenerateKeys"} # type: ignore + regenerate_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/regenerateKeys" + } + + @overload + async def check_name_availability( + self, parameters: _models.CheckNameAvailability, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param parameters: Parameters to check availability of the given namespace name. Required. + :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.CheckNameAvailability + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckNameAvailabilityResult or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + async def check_name_availability( + self, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param parameters: Parameters to check availability of the given namespace name. Required. + :type 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: CheckNameAvailabilityResult or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def check_name_availability( - self, - parameters: _models.CheckNameAvailability, - **kwargs: Any + self, parameters: Union[_models.CheckNameAvailability, IO], **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Check the give namespace name availability. - :param parameters: Parameters to check availability of the given namespace name. - :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.CheckNameAvailability + :param parameters: Parameters to check availability of the given namespace name. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.CheckNameAvailability 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: CheckNameAvailabilityResult, or the result of cls(response) + :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.CheckNameAvailabilityResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.CheckNameAvailabilityResult] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CheckNameAvailabilityResult] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'CheckNameAvailability') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "CheckNameAvailability") 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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -540,50 +759,118 @@ async def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) + deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/CheckNameAvailability"} # type: ignore - + check_name_availability.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/CheckNameAvailability" + } - @distributed_trace_async + @overload async def migrate( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, parameters: _models.SBNamespaceMigrate, + *, + content_type: str = "application/json", **kwargs: Any ) -> None: """This operation Migrate the given namespace to provided name type. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: Parameters supplied to migrate namespace type. + :param parameters: Parameters supplied to migrate namespace type. Required. :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.SBNamespaceMigrate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default 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: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def migrate( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """This operation Migrate the given namespace to provided name type. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to migrate namespace type. Required. + :type 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: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def migrate( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + namespace_name: str, + parameters: Union[_models.SBNamespaceMigrate, IO], + **kwargs: Any + ) -> None: + """This operation Migrate the given namespace to provided name type. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to migrate namespace type. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.SBNamespaceMigrate 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: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'SBNamespaceMigrate') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBNamespaceMigrate") request = build_migrate_request( resource_group_name=resource_group_name, @@ -592,18 +879,18 @@ async def migrate( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, json=_json, - template_url=self.migrate.metadata['url'], + content=_content, + template_url=self.migrate.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -614,57 +901,62 @@ async def migrate( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - migrate.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrate"} # type: ignore - + migrate.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrate" + } @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable[_models.SBNamespaceListResult]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.SBNamespace"]: """Gets all the available namespaces within the subscription, irrespective of the resource groups. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBNamespaceListResult or the result of - cls(response) + :return: An iterator like instance of either SBNamespace or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.SBNamespaceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.SBNamespace] + :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', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBNamespaceListResult] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[_models.SBNamespaceListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -672,16 +964,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("SBNamespaceListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -692,65 +982,65 @@ 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': "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/namespaces"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/namespaces"} @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.SBNamespaceListResult]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.SBNamespace"]: """Gets the available namespaces within a resource group. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. 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 SBNamespaceListResult or the result of - cls(response) + :return: An iterator like instance of either SBNamespace or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.SBNamespaceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.SBNamespace] + :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', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBNamespaceListResult] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[_models.SBNamespaceListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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'], + 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 + request.url = self._client.format_url(request.url) else: - - 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=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -758,16 +1048,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("SBNamespaceListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -778,90 +1066,139 @@ 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.ServiceBus/namespaces"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces" + } async def _create_or_update_initial( - self, - resource_group_name: str, - namespace_name: str, - parameters: _models.SBNamespace, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, parameters: Union[_models.SBNamespace, IO], **kwargs: Any ) -> Optional[_models.SBNamespace]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.SBNamespace]] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.SBNamespace]] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'SBNamespace') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBNamespace") - request = build_create_or_update_request_initial( + request = build_create_or_update_request( resource_group_name=resource_group_name, namespace_name=namespace_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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('SBNamespace', pipeline_response) + deserialized = self._deserialize("SBNamespace", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('SBNamespace', pipeline_response) + deserialized = self._deserialize("SBNamespace", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}" + } - - @distributed_trace_async + @overload async def begin_create_or_update( self, resource_group_name: str, namespace_name: str, parameters: _models.SBNamespace, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.SBNamespace]: """Creates or updates a service namespace. Once created, this namespace's resource manifest is immutable. This operation is idempotent. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: Parameters supplied to create a namespace resource. + :param parameters: Parameters supplied to create a namespace resource. Required. :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.SBNamespace + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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 SBNamespace or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.servicebus.v2017_04_01.models.SBNamespace] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.SBNamespace]: + """Creates or updates a service namespace. Once created, this namespace's resource manifest is + immutable. This operation is idempotent. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to create a namespace resource. Required. + :type 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 :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 @@ -874,121 +1211,143 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.servicebus.v2017_04_01.models.SBNamespace] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, resource_group_name: str, namespace_name: str, parameters: Union[_models.SBNamespace, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.SBNamespace]: + """Creates or updates a service namespace. Once created, this namespace's resource manifest is + immutable. This operation is idempotent. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to create a namespace resource. Is either a model type + or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.SBNamespace 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 SBNamespace or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.servicebus.v2017_04_01.models.SBNamespace] + :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', "2017-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBNamespace] - 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] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SBNamespace] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._create_or_update_initial( # type: ignore + raw_result = await self._create_or_update_initial( resource_group_name=resource_group_name, namespace_name=namespace_name, parameters=parameters, 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): - deserialized = self._deserialize('SBNamespace', pipeline_response) + deserialized = self._deserialize("SBNamespace", 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 + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, **kwargs: Any ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request_initial( + request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + 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 + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}" + } @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete(self, resource_group_name: str, namespace_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes an existing namespace. This operation also removes all associated resources under the namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_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. @@ -1000,103 +1359,94 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements 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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: 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] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, namespace_name=namespace_name, api_version=api_version, - 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 = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}" + } @distributed_trace_async - async def get( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> _models.SBNamespace: + async def get(self, resource_group_name: str, namespace_name: str, **kwargs: Any) -> _models.SBNamespace: """Gets a description for the specified namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBNamespace, or the result of cls(response) + :return: SBNamespace or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.SBNamespace - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBNamespace] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[_models.SBNamespace] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1104,51 +1454,121 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBNamespace', pipeline_response) + deserialized = self._deserialize("SBNamespace", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}" + } - - @distributed_trace_async + @overload async def update( self, resource_group_name: str, namespace_name: str, parameters: _models.SBNamespaceUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> Optional[_models.SBNamespace]: """Updates a service namespace. Once created, this namespace's resource manifest is immutable. This operation is idempotent. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: Parameters supplied to update a namespace resource. + :param parameters: Parameters supplied to update a namespace resource. Required. :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.SBNamespaceUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBNamespace, or the result of cls(response) + :return: SBNamespace or None or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.SBNamespace or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> Optional[_models.SBNamespace]: + """Updates a service namespace. Once created, this namespace's resource manifest is immutable. + This operation is idempotent. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to update a namespace resource. Required. + :type 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: SBNamespace or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.SBNamespace or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + namespace_name: str, + parameters: Union[_models.SBNamespaceUpdateParameters, IO], + **kwargs: Any + ) -> Optional[_models.SBNamespace]: + """Updates a service namespace. Once created, this namespace's resource manifest is immutable. + This operation is idempotent. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to update a namespace resource. Is either a model type + or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.SBNamespaceUpdateParameters 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: SBNamespace or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.SBNamespace or None + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.SBNamespace]] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.SBNamespace]] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'SBNamespaceUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBNamespaceUpdateParameters") request = build_update_request( resource_group_name=resource_group_name, @@ -1157,18 +1577,18 @@ async def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -1178,53 +1598,120 @@ async def update( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('SBNamespace', pipeline_response) + deserialized = self._deserialize("SBNamespace", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('SBNamespace', pipeline_response) + deserialized = self._deserialize("SBNamespace", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}" + } - - @distributed_trace_async + @overload async def create_or_update_network_rule_set( self, resource_group_name: str, namespace_name: str, parameters: _models.NetworkRuleSet, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.NetworkRuleSet: """Create or update NetworkRuleSet for a Namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: The Namespace IpFilterRule. + :param parameters: The Namespace IpFilterRule. Required. :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.NetworkRuleSet + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: NetworkRuleSet or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.NetworkRuleSet + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_network_rule_set( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.NetworkRuleSet: + """Create or update NetworkRuleSet for a Namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: The Namespace IpFilterRule. Required. + :type 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: NetworkRuleSet, or the result of cls(response) + :return: NetworkRuleSet or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.NetworkRuleSet - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update_network_rule_set( + self, + resource_group_name: str, + namespace_name: str, + parameters: Union[_models.NetworkRuleSet, IO], + **kwargs: Any + ) -> _models.NetworkRuleSet: + """Create or update NetworkRuleSet for a Namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: The Namespace IpFilterRule. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.NetworkRuleSet 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: NetworkRuleSet or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.NetworkRuleSet + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.NetworkRuleSet] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.NetworkRuleSet] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'NetworkRuleSet') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "NetworkRuleSet") request = build_create_or_update_network_rule_set_request( resource_group_name=resource_group_name, @@ -1233,18 +1720,18 @@ async def create_or_update_network_rule_set( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_network_rule_set.metadata['url'], + content=_content, + template_url=self.create_or_update_network_rule_set.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1252,63 +1739,62 @@ async def create_or_update_network_rule_set( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('NetworkRuleSet', pipeline_response) + deserialized = self._deserialize("NetworkRuleSet", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_network_rule_set.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default"} # type: ignore - + create_or_update_network_rule_set.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default" + } @distributed_trace_async async def get_network_rule_set( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, **kwargs: Any ) -> _models.NetworkRuleSet: """Gets NetworkRuleSet for a Namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: NetworkRuleSet, or the result of cls(response) + :return: NetworkRuleSet or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.NetworkRuleSet - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.NetworkRuleSet] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[_models.NetworkRuleSet] = kwargs.pop("cls", None) - request = build_get_network_rule_set_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_network_rule_set.metadata['url'], + template_url=self.get_network_rule_set.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1316,74 +1802,77 @@ async def get_network_rule_set( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('NetworkRuleSet', pipeline_response) + deserialized = self._deserialize("NetworkRuleSet", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_network_rule_set.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default"} # type: ignore - + get_network_rule_set.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default" + } @distributed_trace def list_network_rule_sets( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.NetworkRuleSetListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> AsyncIterable["_models.NetworkRuleSet"]: """Gets list of NetworkRuleSet for a Namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either NetworkRuleSetListResult or the result of - cls(response) + :return: An iterator like instance of either NetworkRuleSet or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.NetworkRuleSetListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.NetworkRuleSet] + :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', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.NetworkRuleSetListResult] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[_models.NetworkRuleSetListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_network_rule_sets_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_network_rule_sets.metadata['url'], + template_url=self.list_network_rule_sets.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_network_rule_sets_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -1391,16 +1880,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("NetworkRuleSetListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1411,8 +1898,8 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_network_rule_sets.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets"} # type: ignore + list_network_rule_sets.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/_operations.py index 956ee24cfe1b2..df484d5a7b511 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/_operations.py @@ -6,10 +6,19 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +29,15 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._operations import build_list_request -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class Operations: """ .. warning:: @@ -42,52 +57,57 @@ def __init__(self, *args, **kwargs) -> None: 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 ServiceBus 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.servicebus.v2017_04_01.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2017_04_01.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', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_request( - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -95,16 +115,14 @@ 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) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -115,8 +133,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.ServiceBus/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.ServiceBus/operations"} diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/_patch.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/_patch.py index 0ad201a8c586e..f7dd32510333d 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/_patch.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/_premium_messaging_regions_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/_premium_messaging_regions_operations.py index a9cf8690163e5..15819c78877ff 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/_premium_messaging_regions_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/_premium_messaging_regions_operations.py @@ -6,10 +6,19 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +29,15 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._premium_messaging_regions_operations import build_list_request -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class PremiumMessagingRegionsOperations: """ .. warning:: @@ -42,55 +57,59 @@ def __init__(self, *args, **kwargs) -> None: 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.PremiumMessagingRegionsListResult]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.PremiumMessagingRegions"]: """Gets the available premium messaging regions for servicebus. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PremiumMessagingRegionsListResult or the result of + :return: An iterator like instance of either PremiumMessagingRegions or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.PremiumMessagingRegionsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.PremiumMessagingRegions] + :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', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PremiumMessagingRegionsListResult] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[_models.PremiumMessagingRegionsListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -98,16 +117,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("PremiumMessagingRegionsListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -118,8 +135,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': "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/premiumMessagingRegions"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/premiumMessagingRegions"} diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/_queues_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/_queues_operations.py index 5fbdc0c15c439..8760dd1f629bc 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/_queues_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/_queues_operations.py @@ -6,10 +6,19 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,27 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._queues_operations import build_create_or_update_authorization_rule_request, build_create_or_update_request, build_delete_authorization_rule_request, build_delete_request, build_get_authorization_rule_request, build_get_request, build_list_authorization_rules_request, build_list_by_namespace_request, build_list_keys_request, build_regenerate_keys_request -T = TypeVar('T') +from ...operations._queues_operations import ( + build_create_or_update_authorization_rule_request, + build_create_or_update_request, + build_delete_authorization_rule_request, + build_delete_request, + build_get_authorization_rule_request, + build_get_request, + build_list_authorization_rules_request, + build_list_by_namespace_request, + build_list_keys_request, + build_regenerate_keys_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class QueuesOperations: """ .. warning:: @@ -43,70 +69,69 @@ def __init__(self, *args, **kwargs) -> None: 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_authorization_rules( - self, - resource_group_name: str, - namespace_name: str, - queue_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.SBAuthorizationRuleListResult]: + self, resource_group_name: str, namespace_name: str, queue_name: str, **kwargs: Any + ) -> AsyncIterable["_models.SBAuthorizationRule"]: """Gets all authorization rules for a queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of - cls(response) + :return: An iterator like instance of either SBAuthorizationRule or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRule] + :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', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRuleListResult] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[_models.SBAuthorizationRuleListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_authorization_rules_request( resource_group_name=resource_group_name, namespace_name=namespace_name, queue_name=queue_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_authorization_rules.metadata['url'], + template_url=self.list_authorization_rules.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_authorization_rules_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - queue_name=queue_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -114,16 +139,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("SBAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -134,13 +157,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_authorization_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules"} # type: ignore + list_authorization_rules.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules" + } - @distributed_trace_async + @overload async def create_or_update_authorization_rule( self, resource_group_name: str, @@ -148,38 +171,117 @@ async def create_or_update_authorization_rule( queue_name: str, authorization_rule_name: str, parameters: _models.SBAuthorizationRule, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SBAuthorizationRule: """Creates an authorization rule for a queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: The shared access authorization rule. + :param parameters: The shared access authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBAuthorizationRule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates an authorization rule for a queue. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Required. + :type 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: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: Union[_models.SBAuthorizationRule, IO], + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates an authorization rule for a queue. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRule 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: SBAuthorizationRule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SBAuthorizationRule] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'SBAuthorizationRule') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBAuthorizationRule") request = build_create_or_update_authorization_rule_request( resource_group_name=resource_group_name, @@ -190,18 +292,18 @@ async def create_or_update_authorization_rule( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_authorization_rule.metadata['url'], + content=_content, + template_url=self.create_or_update_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -209,15 +311,16 @@ async def create_or_update_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}"} # type: ignore - + create_or_update_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}" + } @distributed_trace_async async def delete_authorization_rule( # pylint: disable=inconsistent-return-statements @@ -230,31 +333,33 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat ) -> None: """Deletes a queue authorization rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -262,18 +367,17 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_authorization_rule.metadata['url'], + template_url=self.delete_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -284,8 +388,9 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat if cls: return cls(pipeline_response, None, {}) - delete_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}"} # type: ignore - + delete_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}" + } @distributed_trace_async async def get_authorization_rule( @@ -298,31 +403,33 @@ async def get_authorization_rule( ) -> _models.SBAuthorizationRule: """Gets an authorization rule for a queue by rule name. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[_models.SBAuthorizationRule] = kwargs.pop("cls", None) - request = build_get_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -330,18 +437,17 @@ async def get_authorization_rule( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_authorization_rule.metadata['url'], + template_url=self.get_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -349,15 +455,16 @@ async def get_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}"} # type: ignore - + get_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}" + } @distributed_trace_async async def list_keys( @@ -370,31 +477,33 @@ async def list_keys( ) -> _models.AccessKeys: """Primary and secondary connection strings to the queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[_models.AccessKeys] = kwargs.pop("cls", None) - request = build_list_keys_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -402,18 +511,17 @@ async def list_keys( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata['url'], + 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 + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -421,17 +529,18 @@ async def list_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + deserialized = self._deserialize("AccessKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/ListKeys"} # type: ignore - + list_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/ListKeys" + } - @distributed_trace_async + @overload async def regenerate_keys( self, resource_group_name: str, @@ -439,38 +548,117 @@ async def regenerate_keys( queue_name: str, authorization_rule_name: str, parameters: _models.RegenerateAccessKeyParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.AccessKeys: """Regenerates the primary or secondary connection strings to the queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate the authorization rule. + :param parameters: Parameters supplied to regenerate the authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.RegenerateAccessKeyParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AccessKeys: + """Regenerates the primary or secondary connection strings to the queue. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Required. + :type 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: AccessKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: Union[_models.RegenerateAccessKeyParameters, IO], + **kwargs: Any + ) -> _models.AccessKeys: + """Regenerates the primary or secondary connection strings to the queue. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.RegenerateAccessKeyParameters 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: AccessKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AccessKeys] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RegenerateAccessKeyParameters") request = build_regenerate_keys_request( resource_group_name=resource_group_name, @@ -481,18 +669,18 @@ async def regenerate_keys( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_keys.metadata['url'], + content=_content, + template_url=self.regenerate_keys.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -500,15 +688,16 @@ async def regenerate_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + deserialized = self._deserialize("AccessKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/regenerateKeys"} # type: ignore - + regenerate_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/regenerateKeys" + } @distributed_trace def list_by_namespace( @@ -518,12 +707,12 @@ def list_by_namespace( skip: Optional[int] = None, top: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable[_models.SBQueueListResult]: + ) -> AsyncIterable["_models.SBQueue"]: """Gets the queues within a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :param skip: Skip is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skip @@ -533,53 +722,57 @@ def list_by_namespace( Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBQueueListResult or the result of cls(response) + :return: An iterator like instance of either SBQueue or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.SBQueueListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.SBQueue] + :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', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBQueueListResult] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[_models.SBQueueListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_namespace_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, - api_version=api_version, skip=skip, top=top, - template_url=self.list_by_namespace.metadata['url'], + api_version=api_version, + template_url=self.list_by_namespace.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_by_namespace_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - skip=skip, - top=top, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -587,16 +780,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("SBQueueListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -607,49 +798,122 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_namespace.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues"} # type: ignore + list_by_namespace.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues" + } - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, namespace_name: str, queue_name: str, parameters: _models.SBQueue, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SBQueue: """Creates or updates a Service Bus queue. This operation is idempotent. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param parameters: Parameters supplied to create or update a queue resource. + :param parameters: Parameters supplied to create or update a queue resource. Required. :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.SBQueue + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBQueue or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.SBQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBQueue: + """Creates or updates a Service Bus queue. This operation is idempotent. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param parameters: Parameters supplied to create or update a queue resource. Required. + :type 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: SBQueue, or the result of cls(response) + :return: SBQueue or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.SBQueue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + parameters: Union[_models.SBQueue, IO], + **kwargs: Any + ) -> _models.SBQueue: + """Creates or updates a Service Bus queue. This operation is idempotent. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param parameters: Parameters supplied to create or update a queue resource. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.SBQueue 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: SBQueue or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.SBQueue + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBQueue] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SBQueue] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'SBQueue') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBQueue") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -659,18 +923,18 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - 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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -678,67 +942,65 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBQueue', pipeline_response) + deserialized = self._deserialize("SBQueue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}"} # type: ignore - + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}" + } @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - queue_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, queue_name: str, **kwargs: Any ) -> None: """Deletes a queue from the specified namespace in a resource group. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, queue_name=queue_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -749,60 +1011,58 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}"} # type: ignore - + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}" + } @distributed_trace_async async def get( - self, - resource_group_name: str, - namespace_name: str, - queue_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, queue_name: str, **kwargs: Any ) -> _models.SBQueue: """Returns a description for the specified queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBQueue, or the result of cls(response) + :return: SBQueue or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.SBQueue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBQueue] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[_models.SBQueue] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, queue_name=queue_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -810,12 +1070,13 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBQueue', pipeline_response) + deserialized = self._deserialize("SBQueue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/_regions_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/_regions_operations.py index 67a69b7ed6c51..25e1cf16f4892 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/_regions_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/_regions_operations.py @@ -6,10 +6,19 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +29,15 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._regions_operations import build_list_by_sku_request -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class RegionsOperations: """ .. warning:: @@ -42,60 +57,62 @@ def __init__(self, *args, **kwargs) -> None: 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_sku( - self, - sku: str, - **kwargs: Any - ) -> AsyncIterable[_models.PremiumMessagingRegionsListResult]: + def list_by_sku(self, sku: str, **kwargs: Any) -> AsyncIterable["_models.PremiumMessagingRegions"]: """Gets the available Regions for a given sku. - :param sku: The sku type. + :param sku: The sku type. Required. :type sku: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PremiumMessagingRegionsListResult or the result of + :return: An iterator like instance of either PremiumMessagingRegions or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.PremiumMessagingRegionsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.PremiumMessagingRegions] + :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', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PremiumMessagingRegionsListResult] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[_models.PremiumMessagingRegionsListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_sku_request( - subscription_id=self._config.subscription_id, sku=sku, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_sku.metadata['url'], + template_url=self.list_by_sku.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_by_sku_request( - subscription_id=self._config.subscription_id, - sku=sku, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -103,16 +120,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("PremiumMessagingRegionsListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -123,8 +138,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_sku.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/sku/{sku}/regions"} # type: ignore + list_by_sku.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/sku/{sku}/regions"} diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/_rules_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/_rules_operations.py index 9ca2cb43ddcaa..b0982196f6eee 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/_rules_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/_rules_operations.py @@ -6,10 +6,19 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,21 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._rules_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_by_subscriptions_request -T = TypeVar('T') +from ...operations._rules_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_subscriptions_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class RulesOperations: """ .. warning:: @@ -43,7 +63,6 @@ def __init__(self, *args, **kwargs) -> None: 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_subscriptions( self, @@ -54,16 +73,16 @@ def list_by_subscriptions( skip: Optional[int] = None, top: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable[_models.RuleListResult]: + ) -> AsyncIterable["_models.Rule"]: """List all the rules within given topic-subscription. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str :param skip: Skip is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skip @@ -73,57 +92,58 @@ def list_by_subscriptions( Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RuleListResult or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.RuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Rule or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.Rule] + :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', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.RuleListResult] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[_models.RuleListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscriptions_request( resource_group_name=resource_group_name, namespace_name=namespace_name, topic_name=topic_name, subscription_name=subscription_name, subscription_id=self._config.subscription_id, - api_version=api_version, skip=skip, top=top, - template_url=self.list_by_subscriptions.metadata['url'], + api_version=api_version, + template_url=self.list_by_subscriptions.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_by_subscriptions_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - topic_name=topic_name, - subscription_name=subscription_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - skip=skip, - top=top, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -131,16 +151,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("RuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -151,13 +169,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_subscriptions.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules"} # type: ignore + list_by_subscriptions.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules" + } - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, @@ -166,40 +184,125 @@ async def create_or_update( subscription_name: str, rule_name: str, parameters: _models.Rule, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.Rule: """Creates a new rule and updates an existing rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str - :param rule_name: The rule name. + :param rule_name: The rule name. Required. :type rule_name: str - :param parameters: Parameters supplied to create a rule. + :param parameters: Parameters supplied to create a rule. Required. :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.Rule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Rule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.Rule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Rule: + """Creates a new rule and updates an existing rule. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param rule_name: The rule name. Required. + :type rule_name: str + :param parameters: Parameters supplied to create a rule. Required. + :type 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: Rule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.Rule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + rule_name: str, + parameters: Union[_models.Rule, IO], + **kwargs: Any + ) -> _models.Rule: + """Creates a new rule and updates an existing rule. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param rule_name: The rule name. Required. + :type rule_name: str + :param parameters: Parameters supplied to create a rule. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.Rule 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: Rule, or the result of cls(response) + :return: Rule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.Rule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.Rule] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Rule] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'Rule') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Rule") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -211,18 +314,18 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - 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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -230,15 +333,16 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Rule', pipeline_response) + deserialized = self._deserialize("Rule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}"} # type: ignore - + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}" + } @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -252,33 +356,35 @@ async def delete( # pylint: disable=inconsistent-return-statements ) -> None: """Deletes an existing rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str - :param rule_name: The rule name. + :param rule_name: The rule name. Required. :type rule_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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -287,18 +393,17 @@ async def delete( # pylint: disable=inconsistent-return-statements rule_name=rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -309,8 +414,9 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}"} # type: ignore - + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}" + } @distributed_trace_async async def get( @@ -324,33 +430,35 @@ async def get( ) -> _models.Rule: """Retrieves the description for the specified rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str - :param rule_name: The rule name. + :param rule_name: The rule name. Required. :type rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Rule, or the result of cls(response) + :return: Rule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.Rule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Rule] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[_models.Rule] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -359,18 +467,17 @@ async def get( rule_name=rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -378,12 +485,13 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Rule', pipeline_response) + deserialized = self._deserialize("Rule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/_subscriptions_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/_subscriptions_operations.py index 861b32e683c22..5fad0b3f49aa8 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/_subscriptions_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/_subscriptions_operations.py @@ -6,10 +6,19 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,21 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._subscriptions_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_by_topic_request -T = TypeVar('T') +from ...operations._subscriptions_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_topic_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class SubscriptionsOperations: """ .. warning:: @@ -43,7 +63,6 @@ def __init__(self, *args, **kwargs) -> None: 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_topic( self, @@ -53,14 +72,14 @@ def list_by_topic( skip: Optional[int] = None, top: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable[_models.SBSubscriptionListResult]: + ) -> AsyncIterable["_models.SBSubscription"]: """List all the subscriptions under a specified topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str :param skip: Skip is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skip @@ -70,56 +89,58 @@ def list_by_topic( Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBSubscriptionListResult or the result of - cls(response) + :return: An iterator like instance of either SBSubscription or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.SBSubscriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.SBSubscription] + :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', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBSubscriptionListResult] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[_models.SBSubscriptionListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_topic_request( resource_group_name=resource_group_name, namespace_name=namespace_name, topic_name=topic_name, subscription_id=self._config.subscription_id, - api_version=api_version, skip=skip, top=top, - template_url=self.list_by_topic.metadata['url'], + api_version=api_version, + template_url=self.list_by_topic.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_by_topic_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - topic_name=topic_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - skip=skip, - top=top, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -127,16 +148,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("SBSubscriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -147,13 +166,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_topic.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions"} # type: ignore + list_by_topic.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions" + } - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, @@ -161,38 +180,117 @@ async def create_or_update( topic_name: str, subscription_name: str, parameters: _models.SBSubscription, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SBSubscription: """Creates a topic subscription. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str - :param parameters: Parameters supplied to create a subscription resource. + :param parameters: Parameters supplied to create a subscription resource. Required. :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.SBSubscription + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBSubscription, or the result of cls(response) + :return: SBSubscription or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.SBSubscription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBSubscription: + """Creates a topic subscription. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param parameters: Parameters supplied to create a subscription resource. Required. + :type 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: SBSubscription or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.SBSubscription + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + parameters: Union[_models.SBSubscription, IO], + **kwargs: Any + ) -> _models.SBSubscription: + """Creates a topic subscription. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param parameters: Parameters supplied to create a subscription resource. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.SBSubscription 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: SBSubscription or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.SBSubscription + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBSubscription] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SBSubscription] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'SBSubscription') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBSubscription") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -203,18 +301,18 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - 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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -222,52 +320,50 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBSubscription', pipeline_response) + deserialized = self._deserialize("SBSubscription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}"} # type: ignore - + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}" + } @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - subscription_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, topic_name: str, subscription_name: str, **kwargs: Any ) -> None: """Deletes a subscription from the specified topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -275,18 +371,17 @@ async def delete( # pylint: disable=inconsistent-return-statements subscription_name=subscription_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -297,45 +392,43 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}"} # type: ignore - + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}" + } @distributed_trace_async async def get( - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - subscription_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, topic_name: str, subscription_name: str, **kwargs: Any ) -> _models.SBSubscription: """Returns a subscription description for the specified topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBSubscription, or the result of cls(response) + :return: SBSubscription or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.SBSubscription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBSubscription] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[_models.SBSubscription] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -343,18 +436,17 @@ async def get( subscription_name=subscription_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -362,12 +454,13 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBSubscription', pipeline_response) + deserialized = self._deserialize("SBSubscription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/_topics_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/_topics_operations.py index 4814085f44a26..a13bbf871524e 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/_topics_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/_topics_operations.py @@ -6,10 +6,19 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,27 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._topics_operations import build_create_or_update_authorization_rule_request, build_create_or_update_request, build_delete_authorization_rule_request, build_delete_request, build_get_authorization_rule_request, build_get_request, build_list_authorization_rules_request, build_list_by_namespace_request, build_list_keys_request, build_regenerate_keys_request -T = TypeVar('T') +from ...operations._topics_operations import ( + build_create_or_update_authorization_rule_request, + build_create_or_update_request, + build_delete_authorization_rule_request, + build_delete_request, + build_get_authorization_rule_request, + build_get_request, + build_list_authorization_rules_request, + build_list_by_namespace_request, + build_list_keys_request, + build_regenerate_keys_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class TopicsOperations: """ .. warning:: @@ -43,70 +69,69 @@ def __init__(self, *args, **kwargs) -> None: 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_authorization_rules( - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.SBAuthorizationRuleListResult]: + self, resource_group_name: str, namespace_name: str, topic_name: str, **kwargs: Any + ) -> AsyncIterable["_models.SBAuthorizationRule"]: """Gets authorization rules for a topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of - cls(response) + :return: An iterator like instance of either SBAuthorizationRule or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRule] + :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', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRuleListResult] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[_models.SBAuthorizationRuleListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_authorization_rules_request( resource_group_name=resource_group_name, namespace_name=namespace_name, topic_name=topic_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_authorization_rules.metadata['url'], + template_url=self.list_authorization_rules.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_authorization_rules_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - topic_name=topic_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -114,16 +139,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("SBAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -134,13 +157,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_authorization_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules"} # type: ignore + list_authorization_rules.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules" + } - @distributed_trace_async + @overload async def create_or_update_authorization_rule( self, resource_group_name: str, @@ -148,38 +171,117 @@ async def create_or_update_authorization_rule( topic_name: str, authorization_rule_name: str, parameters: _models.SBAuthorizationRule, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SBAuthorizationRule: """Creates an authorization rule for the specified topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: The shared access authorization rule. + :param parameters: The shared access authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBAuthorizationRule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates an authorization rule for the specified topic. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Required. + :type 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: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: Union[_models.SBAuthorizationRule, IO], + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates an authorization rule for the specified topic. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRule 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: SBAuthorizationRule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SBAuthorizationRule] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'SBAuthorizationRule') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBAuthorizationRule") request = build_create_or_update_authorization_rule_request( resource_group_name=resource_group_name, @@ -190,18 +292,18 @@ async def create_or_update_authorization_rule( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_authorization_rule.metadata['url'], + content=_content, + template_url=self.create_or_update_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -209,15 +311,16 @@ async def create_or_update_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}"} # type: ignore - + create_or_update_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}" + } @distributed_trace_async async def get_authorization_rule( @@ -230,31 +333,33 @@ async def get_authorization_rule( ) -> _models.SBAuthorizationRule: """Returns the specified authorization rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[_models.SBAuthorizationRule] = kwargs.pop("cls", None) - request = build_get_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -262,18 +367,17 @@ async def get_authorization_rule( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_authorization_rule.metadata['url'], + template_url=self.get_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -281,15 +385,16 @@ async def get_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}"} # type: ignore - + get_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}" + } @distributed_trace_async async def delete_authorization_rule( # pylint: disable=inconsistent-return-statements @@ -302,31 +407,33 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat ) -> None: """Deletes a topic authorization rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -334,18 +441,17 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_authorization_rule.metadata['url'], + template_url=self.delete_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -356,8 +462,9 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat if cls: return cls(pipeline_response, None, {}) - delete_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}"} # type: ignore - + delete_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}" + } @distributed_trace_async async def list_keys( @@ -370,31 +477,33 @@ async def list_keys( ) -> _models.AccessKeys: """Gets the primary and secondary connection strings for the topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[_models.AccessKeys] = kwargs.pop("cls", None) - request = build_list_keys_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -402,18 +511,17 @@ async def list_keys( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata['url'], + 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 + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -421,17 +529,18 @@ async def list_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + deserialized = self._deserialize("AccessKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/ListKeys"} # type: ignore - + list_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/ListKeys" + } - @distributed_trace_async + @overload async def regenerate_keys( self, resource_group_name: str, @@ -439,38 +548,117 @@ async def regenerate_keys( topic_name: str, authorization_rule_name: str, parameters: _models.RegenerateAccessKeyParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.AccessKeys: """Regenerates primary or secondary connection strings for the topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate the authorization rule. + :param parameters: Parameters supplied to regenerate the authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.RegenerateAccessKeyParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AccessKeys: + """Regenerates primary or secondary connection strings for the topic. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Required. + :type 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: AccessKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: Union[_models.RegenerateAccessKeyParameters, IO], + **kwargs: Any + ) -> _models.AccessKeys: + """Regenerates primary or secondary connection strings for the topic. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.RegenerateAccessKeyParameters 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: AccessKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AccessKeys] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RegenerateAccessKeyParameters") request = build_regenerate_keys_request( resource_group_name=resource_group_name, @@ -481,18 +669,18 @@ async def regenerate_keys( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_keys.metadata['url'], + content=_content, + template_url=self.regenerate_keys.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -500,15 +688,16 @@ async def regenerate_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + deserialized = self._deserialize("AccessKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/regenerateKeys"} # type: ignore - + regenerate_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/regenerateKeys" + } @distributed_trace def list_by_namespace( @@ -518,12 +707,12 @@ def list_by_namespace( skip: Optional[int] = None, top: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable[_models.SBTopicListResult]: + ) -> AsyncIterable["_models.SBTopic"]: """Gets all the topics in a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :param skip: Skip is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skip @@ -533,53 +722,57 @@ def list_by_namespace( Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBTopicListResult or the result of cls(response) + :return: An iterator like instance of either SBTopic or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.SBTopicListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.SBTopic] + :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', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBTopicListResult] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[_models.SBTopicListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_namespace_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, - api_version=api_version, skip=skip, top=top, - template_url=self.list_by_namespace.metadata['url'], + api_version=api_version, + template_url=self.list_by_namespace.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_by_namespace_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - skip=skip, - top=top, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -587,16 +780,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("SBTopicListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -607,49 +798,122 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_namespace.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics"} # type: ignore + list_by_namespace.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics" + } - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, namespace_name: str, topic_name: str, parameters: _models.SBTopic, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SBTopic: """Creates a topic in the specified namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param parameters: Parameters supplied to create a topic resource. + :param parameters: Parameters supplied to create a topic resource. Required. :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.SBTopic + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBTopic or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.SBTopic + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBTopic: + """Creates a topic in the specified namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param parameters: Parameters supplied to create a topic resource. Required. + :type 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: SBTopic, or the result of cls(response) + :return: SBTopic or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.SBTopic - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + parameters: Union[_models.SBTopic, IO], + **kwargs: Any + ) -> _models.SBTopic: + """Creates a topic in the specified namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param parameters: Parameters supplied to create a topic resource. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.SBTopic 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: SBTopic or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.SBTopic + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBTopic] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SBTopic] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'SBTopic') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBTopic") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -659,18 +923,18 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - 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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -678,67 +942,65 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBTopic', pipeline_response) + deserialized = self._deserialize("SBTopic", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}"} # type: ignore - + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}" + } @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, topic_name: str, **kwargs: Any ) -> None: """Deletes a topic from the specified namespace and resource group. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, topic_name=topic_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -749,60 +1011,58 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}"} # type: ignore - + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}" + } @distributed_trace_async async def get( - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, topic_name: str, **kwargs: Any ) -> _models.SBTopic: """Returns a description for the specified topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBTopic, or the result of cls(response) + :return: SBTopic or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.SBTopic - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBTopic] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[_models.SBTopic] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, topic_name=topic_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -810,12 +1070,13 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBTopic', pipeline_response) + deserialized = self._deserialize("SBTopic", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/models/__init__.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/models/__init__.py index 9757ddefc7b66..b4d14fae1e818 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/models/__init__.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/models/__init__.py @@ -56,90 +56,88 @@ from ._models_py3 import Subnet from ._models_py3 import TrackedResource - -from ._service_bus_management_client_enums import ( - AccessRights, - DefaultAction, - EncodingCaptureDescription, - EntityStatus, - FilterType, - KeyType, - MigrationConfigurationName, - NameSpaceType, - NetworkRuleIPAction, - ProvisioningStateDR, - RoleDisasterRecovery, - SkuName, - SkuTier, - UnavailableReason, -) +from ._service_bus_management_client_enums import AccessRights +from ._service_bus_management_client_enums import DefaultAction +from ._service_bus_management_client_enums import EncodingCaptureDescription +from ._service_bus_management_client_enums import EntityStatus +from ._service_bus_management_client_enums import FilterType +from ._service_bus_management_client_enums import KeyType +from ._service_bus_management_client_enums import MigrationConfigurationName +from ._service_bus_management_client_enums import NameSpaceType +from ._service_bus_management_client_enums import NetworkRuleIPAction +from ._service_bus_management_client_enums import ProvisioningStateDR +from ._service_bus_management_client_enums import RoleDisasterRecovery +from ._service_bus_management_client_enums import SkuName +from ._service_bus_management_client_enums import SkuTier +from ._service_bus_management_client_enums import UnavailableReason from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'AccessKeys', - 'Action', - 'ArmDisasterRecovery', - 'ArmDisasterRecoveryListResult', - 'CaptureDescription', - 'CheckNameAvailability', - 'CheckNameAvailabilityResult', - 'CorrelationFilter', - 'Destination', - 'ErrorAdditionalInfo', - 'ErrorResponse', - 'ErrorResponseError', - 'EventHubListResult', - 'Eventhub', - 'MessageCountDetails', - 'MigrationConfigListResult', - 'MigrationConfigProperties', - 'NWRuleSetIpRules', - 'NWRuleSetVirtualNetworkRules', - 'NetworkRuleSet', - 'NetworkRuleSetListResult', - 'Operation', - 'OperationDisplay', - 'OperationListResult', - 'PremiumMessagingRegions', - 'PremiumMessagingRegionsListResult', - 'PremiumMessagingRegionsProperties', - 'RegenerateAccessKeyParameters', - 'Resource', - 'ResourceNamespacePatch', - 'Rule', - 'RuleListResult', - 'SBAuthorizationRule', - 'SBAuthorizationRuleListResult', - 'SBNamespace', - 'SBNamespaceListResult', - 'SBNamespaceMigrate', - 'SBNamespaceUpdateParameters', - 'SBQueue', - 'SBQueueListResult', - 'SBSku', - 'SBSubscription', - 'SBSubscriptionListResult', - 'SBTopic', - 'SBTopicListResult', - 'SqlFilter', - 'SqlRuleAction', - 'Subnet', - 'TrackedResource', - 'AccessRights', - 'DefaultAction', - 'EncodingCaptureDescription', - 'EntityStatus', - 'FilterType', - 'KeyType', - 'MigrationConfigurationName', - 'NameSpaceType', - 'NetworkRuleIPAction', - 'ProvisioningStateDR', - 'RoleDisasterRecovery', - 'SkuName', - 'SkuTier', - 'UnavailableReason', + "AccessKeys", + "Action", + "ArmDisasterRecovery", + "ArmDisasterRecoveryListResult", + "CaptureDescription", + "CheckNameAvailability", + "CheckNameAvailabilityResult", + "CorrelationFilter", + "Destination", + "ErrorAdditionalInfo", + "ErrorResponse", + "ErrorResponseError", + "EventHubListResult", + "Eventhub", + "MessageCountDetails", + "MigrationConfigListResult", + "MigrationConfigProperties", + "NWRuleSetIpRules", + "NWRuleSetVirtualNetworkRules", + "NetworkRuleSet", + "NetworkRuleSetListResult", + "Operation", + "OperationDisplay", + "OperationListResult", + "PremiumMessagingRegions", + "PremiumMessagingRegionsListResult", + "PremiumMessagingRegionsProperties", + "RegenerateAccessKeyParameters", + "Resource", + "ResourceNamespacePatch", + "Rule", + "RuleListResult", + "SBAuthorizationRule", + "SBAuthorizationRuleListResult", + "SBNamespace", + "SBNamespaceListResult", + "SBNamespaceMigrate", + "SBNamespaceUpdateParameters", + "SBQueue", + "SBQueueListResult", + "SBSku", + "SBSubscription", + "SBSubscriptionListResult", + "SBTopic", + "SBTopicListResult", + "SqlFilter", + "SqlRuleAction", + "Subnet", + "TrackedResource", + "AccessRights", + "DefaultAction", + "EncodingCaptureDescription", + "EntityStatus", + "FilterType", + "KeyType", + "MigrationConfigurationName", + "NameSpaceType", + "NetworkRuleIPAction", + "ProvisioningStateDR", + "RoleDisasterRecovery", + "SkuName", + "SkuTier", + "UnavailableReason", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/models/_models_py3.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/models/_models_py3.py index 919aaa6fd79cc..b2e9daaf2f988 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/models/_models_py3.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_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. @@ -9,15 +10,14 @@ import datetime from typing import Dict, List, Optional, TYPE_CHECKING, Union -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from ... import _serialization if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - import __init__ as _models + from .. import models as _models -class AccessKeys(msrest.serialization.Model): +class AccessKeys(_serialization.Model): """Namespace/ServiceBus Connection String. Variables are only populated by the server, and will be ignored when sending a request. @@ -45,32 +45,28 @@ class AccessKeys(msrest.serialization.Model): """ _validation = { - 'primary_connection_string': {'readonly': True}, - 'secondary_connection_string': {'readonly': True}, - 'alias_primary_connection_string': {'readonly': True}, - 'alias_secondary_connection_string': {'readonly': True}, - 'primary_key': {'readonly': True}, - 'secondary_key': {'readonly': True}, - 'key_name': {'readonly': True}, + "primary_connection_string": {"readonly": True}, + "secondary_connection_string": {"readonly": True}, + "alias_primary_connection_string": {"readonly": True}, + "alias_secondary_connection_string": {"readonly": True}, + "primary_key": {"readonly": True}, + "secondary_key": {"readonly": True}, + "key_name": {"readonly": True}, } _attribute_map = { - 'primary_connection_string': {'key': 'primaryConnectionString', 'type': 'str'}, - 'secondary_connection_string': {'key': 'secondaryConnectionString', 'type': 'str'}, - 'alias_primary_connection_string': {'key': 'aliasPrimaryConnectionString', 'type': 'str'}, - 'alias_secondary_connection_string': {'key': 'aliasSecondaryConnectionString', 'type': 'str'}, - 'primary_key': {'key': 'primaryKey', 'type': 'str'}, - 'secondary_key': {'key': 'secondaryKey', 'type': 'str'}, - 'key_name': {'key': 'keyName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - """ - """ - super(AccessKeys, self).__init__(**kwargs) + "primary_connection_string": {"key": "primaryConnectionString", "type": "str"}, + "secondary_connection_string": {"key": "secondaryConnectionString", "type": "str"}, + "alias_primary_connection_string": {"key": "aliasPrimaryConnectionString", "type": "str"}, + "alias_secondary_connection_string": {"key": "aliasSecondaryConnectionString", "type": "str"}, + "primary_key": {"key": "primaryKey", "type": "str"}, + "secondary_key": {"key": "secondaryKey", "type": "str"}, + "key_name": {"key": "keyName", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.primary_connection_string = None self.secondary_connection_string = None self.alias_primary_connection_string = None @@ -80,7 +76,7 @@ def __init__( self.key_name = None -class Action(msrest.serialization.Model): +class Action(_serialization.Model): """Represents the filter actions which are allowed for the transformation of a message that have been matched by a filter expression. :ivar sql_expression: SQL expression. e.g. MyProperty='ABC'. @@ -94,9 +90,9 @@ class Action(msrest.serialization.Model): """ _attribute_map = { - 'sql_expression': {'key': 'sqlExpression', 'type': 'str'}, - 'compatibility_level': {'key': 'compatibilityLevel', 'type': 'int'}, - 'requires_preprocessing': {'key': 'requiresPreprocessing', 'type': 'bool'}, + "sql_expression": {"key": "sqlExpression", "type": "str"}, + "compatibility_level": {"key": "compatibilityLevel", "type": "int"}, + "requires_preprocessing": {"key": "requiresPreprocessing", "type": "bool"}, } def __init__( @@ -104,7 +100,7 @@ def __init__( *, sql_expression: Optional[str] = None, compatibility_level: Optional[int] = None, - requires_preprocessing: Optional[bool] = True, + requires_preprocessing: bool = True, **kwargs ): """ @@ -117,13 +113,13 @@ def __init__( preprocessing. :paramtype requires_preprocessing: bool """ - super(Action, self).__init__(**kwargs) + super().__init__(**kwargs) self.sql_expression = sql_expression self.compatibility_level = compatibility_level self.requires_preprocessing = requires_preprocessing -class Resource(msrest.serialization.Model): +class Resource(_serialization.Model): """The Resource definition for other than namespace. Variables are only populated by the server, and will be ignored when sending a request. @@ -137,24 +133,20 @@ class Resource(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(Resource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -173,11 +165,11 @@ class ArmDisasterRecovery(Resource): :vartype type: str :ivar provisioning_state: Provisioning state of the Alias(Disaster Recovery configuration) - possible values 'Accepted' or 'Succeeded' or 'Failed'. Known values are: "Accepted", - "Succeeded", "Failed". + "Succeeded", and "Failed". :vartype provisioning_state: str or ~azure.mgmt.servicebus.v2017_04_01.models.ProvisioningStateDR :ivar pending_replication_operations_count: Number of entities pending to be replicated. - :vartype pending_replication_operations_count: long + :vartype pending_replication_operations_count: int :ivar partner_namespace: ARM Id of the Primary/Secondary eventhub namespace name, which is part of GEO DR pairing. :vartype partner_namespace: str @@ -185,37 +177,31 @@ class ArmDisasterRecovery(Resource): pairing. :vartype alternate_name: str :ivar role: role of namespace in GEO DR - possible values 'Primary' or 'PrimaryNotReplicating' - or 'Secondary'. Known values are: "Primary", "PrimaryNotReplicating", "Secondary". + or 'Secondary'. Known values are: "Primary", "PrimaryNotReplicating", and "Secondary". :vartype role: str or ~azure.mgmt.servicebus.v2017_04_01.models.RoleDisasterRecovery """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'pending_replication_operations_count': {'readonly': True}, - 'role': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "pending_replication_operations_count": {"readonly": True}, + "role": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'pending_replication_operations_count': {'key': 'properties.pendingReplicationOperationsCount', 'type': 'long'}, - 'partner_namespace': {'key': 'properties.partnerNamespace', 'type': 'str'}, - 'alternate_name': {'key': 'properties.alternateName', 'type': 'str'}, - 'role': {'key': 'properties.role', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "pending_replication_operations_count": {"key": "properties.pendingReplicationOperationsCount", "type": "int"}, + "partner_namespace": {"key": "properties.partnerNamespace", "type": "str"}, + "alternate_name": {"key": "properties.alternateName", "type": "str"}, + "role": {"key": "properties.role", "type": "str"}, } - def __init__( - self, - *, - partner_namespace: Optional[str] = None, - alternate_name: Optional[str] = None, - **kwargs - ): + def __init__(self, *, partner_namespace: Optional[str] = None, alternate_name: Optional[str] = None, **kwargs): """ :keyword partner_namespace: ARM Id of the Primary/Secondary eventhub namespace name, which is part of GEO DR pairing. @@ -224,7 +210,7 @@ def __init__( pairing. :paramtype alternate_name: str """ - super(ArmDisasterRecovery, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = None self.pending_replication_operations_count = None self.partner_namespace = partner_namespace @@ -232,7 +218,7 @@ def __init__( self.role = None -class ArmDisasterRecoveryListResult(msrest.serialization.Model): +class ArmDisasterRecoveryListResult(_serialization.Model): """The result of the List Alias(Disaster Recovery configuration) operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -245,36 +231,31 @@ class ArmDisasterRecoveryListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[ArmDisasterRecovery]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ArmDisasterRecovery]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["_models.ArmDisasterRecovery"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.ArmDisasterRecovery"]] = None, **kwargs): """ :keyword value: List of Alias(Disaster Recovery configurations). :paramtype value: list[~azure.mgmt.servicebus.v2017_04_01.models.ArmDisasterRecovery] """ - super(ArmDisasterRecoveryListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class CaptureDescription(msrest.serialization.Model): +class CaptureDescription(_serialization.Model): """Properties to configure capture description for eventhub. :ivar enabled: A value that indicates whether capture description is enabled. :vartype enabled: bool :ivar encoding: Enumerates the possible values for the encoding format of capture description. - Known values are: "Avro", "AvroDeflate". + Known values are: "Avro" and "AvroDeflate". :vartype encoding: str or ~azure.mgmt.servicebus.v2017_04_01.models.EncodingCaptureDescription :ivar interval_in_seconds: The time window allows you to set the frequency with which the capture to Azure Blobs will happen, value should between 60 to 900 seconds. @@ -288,16 +269,16 @@ class CaptureDescription(msrest.serialization.Model): """ _validation = { - 'interval_in_seconds': {'maximum': 900, 'minimum': 60}, - 'size_limit_in_bytes': {'maximum': 524288000, 'minimum': 10485760}, + "interval_in_seconds": {"maximum": 900, "minimum": 60}, + "size_limit_in_bytes": {"maximum": 524288000, "minimum": 10485760}, } _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'encoding': {'key': 'encoding', 'type': 'str'}, - 'interval_in_seconds': {'key': 'intervalInSeconds', 'type': 'int'}, - 'size_limit_in_bytes': {'key': 'sizeLimitInBytes', 'type': 'int'}, - 'destination': {'key': 'destination', 'type': 'Destination'}, + "enabled": {"key": "enabled", "type": "bool"}, + "encoding": {"key": "encoding", "type": "str"}, + "interval_in_seconds": {"key": "intervalInSeconds", "type": "int"}, + "size_limit_in_bytes": {"key": "sizeLimitInBytes", "type": "int"}, + "destination": {"key": "destination", "type": "Destination"}, } def __init__( @@ -314,7 +295,7 @@ def __init__( :keyword enabled: A value that indicates whether capture description is enabled. :paramtype enabled: bool :keyword encoding: Enumerates the possible values for the encoding format of capture - description. Known values are: "Avro", "AvroDeflate". + description. Known values are: "Avro" and "AvroDeflate". :paramtype encoding: str or ~azure.mgmt.servicebus.v2017_04_01.models.EncodingCaptureDescription :keyword interval_in_seconds: The time window allows you to set the frequency with which the @@ -327,7 +308,7 @@ def __init__( Blob Names). :paramtype destination: ~azure.mgmt.servicebus.v2017_04_01.models.Destination """ - super(CaptureDescription, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.encoding = encoding self.interval_in_seconds = interval_in_seconds @@ -335,42 +316,37 @@ def __init__( self.destination = destination -class CheckNameAvailability(msrest.serialization.Model): +class CheckNameAvailability(_serialization.Model): """Description of a Check Name availability request properties. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The Name to check the namespace name availability and The namespace name - can contain only letters, numbers, and hyphens. The namespace must start with a letter, and it - must end with a letter or number. + :ivar name: The Name to check the namespace name availability and The namespace name can + contain only letters, numbers, and hyphens. The namespace must start with a letter, and it must + end with a letter or number. 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 to check the namespace name availability and The namespace - name can contain only letters, numbers, and hyphens. The namespace must start with a letter, - and it must end with a letter or number. + :keyword name: The Name to check the namespace name availability and The namespace name can + contain only letters, numbers, and hyphens. The namespace must start with a letter, and it must + end with a letter or number. Required. :paramtype name: str """ - super(CheckNameAvailability, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class CheckNameAvailabilityResult(msrest.serialization.Model): +class CheckNameAvailabilityResult(_serialization.Model): """Description of a Check Name availability request properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -381,19 +357,19 @@ class CheckNameAvailabilityResult(msrest.serialization.Model): available; otherwise, false. :vartype name_available: bool :ivar reason: The reason for unavailability of a namespace. Known values are: "None", - "InvalidName", "SubscriptionIsDisabled", "NameInUse", "NameInLockdown", + "InvalidName", "SubscriptionIsDisabled", "NameInUse", "NameInLockdown", and "TooManyNamespaceInCurrentSubscription". :vartype reason: str or ~azure.mgmt.servicebus.v2017_04_01.models.UnavailableReason """ _validation = { - 'message': {'readonly': True}, + "message": {"readonly": True}, } _attribute_map = { - 'message': {'key': 'message', 'type': 'str'}, - '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"}, } def __init__( @@ -408,17 +384,17 @@ def __init__( available; otherwise, false. :paramtype name_available: bool :keyword reason: The reason for unavailability of a namespace. Known values are: "None", - "InvalidName", "SubscriptionIsDisabled", "NameInUse", "NameInLockdown", + "InvalidName", "SubscriptionIsDisabled", "NameInUse", "NameInLockdown", and "TooManyNamespaceInCurrentSubscription". :paramtype reason: str or ~azure.mgmt.servicebus.v2017_04_01.models.UnavailableReason """ - super(CheckNameAvailabilityResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.message = None self.name_available = name_available self.reason = reason -class CorrelationFilter(msrest.serialization.Model): +class CorrelationFilter(_serialization.Model): """Represents the correlation filter expression. :ivar properties: dictionary object for custom filters. @@ -445,16 +421,16 @@ class CorrelationFilter(msrest.serialization.Model): """ _attribute_map = { - 'properties': {'key': 'properties', 'type': '{str}'}, - 'correlation_id': {'key': 'correlationId', 'type': 'str'}, - 'message_id': {'key': 'messageId', 'type': 'str'}, - 'to': {'key': 'to', 'type': 'str'}, - 'reply_to': {'key': 'replyTo', 'type': 'str'}, - 'label': {'key': 'label', 'type': 'str'}, - 'session_id': {'key': 'sessionId', 'type': 'str'}, - 'reply_to_session_id': {'key': 'replyToSessionId', 'type': 'str'}, - 'content_type': {'key': 'contentType', 'type': 'str'}, - 'requires_preprocessing': {'key': 'requiresPreprocessing', 'type': 'bool'}, + "properties": {"key": "properties", "type": "{str}"}, + "correlation_id": {"key": "correlationId", "type": "str"}, + "message_id": {"key": "messageId", "type": "str"}, + "to": {"key": "to", "type": "str"}, + "reply_to": {"key": "replyTo", "type": "str"}, + "label": {"key": "label", "type": "str"}, + "session_id": {"key": "sessionId", "type": "str"}, + "reply_to_session_id": {"key": "replyToSessionId", "type": "str"}, + "content_type": {"key": "contentType", "type": "str"}, + "requires_preprocessing": {"key": "requiresPreprocessing", "type": "bool"}, } def __init__( @@ -469,7 +445,7 @@ def __init__( session_id: Optional[str] = None, reply_to_session_id: Optional[str] = None, content_type: Optional[str] = None, - requires_preprocessing: Optional[bool] = True, + requires_preprocessing: bool = True, **kwargs ): """ @@ -495,7 +471,7 @@ def __init__( preprocessing. :paramtype requires_preprocessing: bool """ - super(CorrelationFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties self.correlation_id = correlation_id self.message_id = message_id @@ -508,7 +484,7 @@ def __init__( self.requires_preprocessing = requires_preprocessing -class Destination(msrest.serialization.Model): +class Destination(_serialization.Model): """Capture storage details for capture description. :ivar name: Name for capture destination. @@ -525,10 +501,10 @@ class Destination(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'storage_account_resource_id': {'key': 'properties.storageAccountResourceId', 'type': 'str'}, - 'blob_container': {'key': 'properties.blobContainer', 'type': 'str'}, - 'archive_name_format': {'key': 'properties.archiveNameFormat', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "storage_account_resource_id": {"key": "properties.storageAccountResourceId", "type": "str"}, + "blob_container": {"key": "properties.blobContainer", "type": "str"}, + "archive_name_format": {"key": "properties.archiveNameFormat", "type": "str"}, } def __init__( @@ -553,14 +529,14 @@ def __init__( the parameters (Namespace,EventHub .. etc) are mandatory irrespective of order. :paramtype archive_name_format: str """ - super(Destination, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.storage_account_resource_id = storage_account_resource_id self.blob_container = blob_container self.archive_name_format = archive_name_format -class ErrorAdditionalInfo(msrest.serialization.Model): +class ErrorAdditionalInfo(_serialization.Model): """The resource management error additional info. Variables are only populated by the server, and will be ignored when sending a request. @@ -568,31 +544,27 @@ class ErrorAdditionalInfo(msrest.serialization.Model): :ivar type: The additional info type. :vartype type: str :ivar info: The additional info. - :vartype info: any + :vartype info: JSON """ _validation = { - 'type': {'readonly': True}, - 'info': {'readonly': True}, + "type": {"readonly": True}, + "info": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'info': {'key': 'info', 'type': 'object'}, + "type": {"key": "type", "type": "str"}, + "info": {"key": "info", "type": "object"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorAdditionalInfo, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.type = None self.info = None -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_serialization.Model): """The resource management error response. :ivar error: The error object. @@ -600,24 +572,19 @@ class ErrorResponse(msrest.serialization.Model): """ _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorResponseError'}, + "error": {"key": "error", "type": "ErrorResponseError"}, } - def __init__( - self, - *, - error: Optional["_models.ErrorResponseError"] = None, - **kwargs - ): + def __init__(self, *, error: Optional["_models.ErrorResponseError"] = None, **kwargs): """ :keyword error: The error object. :paramtype error: ~azure.mgmt.servicebus.v2017_04_01.models.ErrorResponseError """ - super(ErrorResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.error = error -class ErrorResponseError(msrest.serialization.Model): +class ErrorResponseError(_serialization.Model): """The error object. Variables are only populated by the server, and will be ignored when sending a request. @@ -635,28 +602,24 @@ class ErrorResponseError(msrest.serialization.Model): """ _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - 'details': {'readonly': True}, - 'additional_info': {'readonly': True}, + "code": {"readonly": True}, + "message": {"readonly": True}, + "target": {"readonly": True}, + "details": {"readonly": True}, + "additional_info": {"readonly": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ErrorResponse]'}, - 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[ErrorResponse]"}, + "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorResponseError, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.code = None self.message = None self.target = None @@ -683,40 +646,40 @@ class Eventhub(Resource): :vartype updated_at: ~datetime.datetime :ivar message_retention_in_days: Number of days to retain the events for this Event Hub, value should be 1 to 7 days. - :vartype message_retention_in_days: long + :vartype message_retention_in_days: int :ivar partition_count: Number of partitions created for the Event Hub, allowed values are from 1 to 32 partitions. - :vartype partition_count: long + :vartype partition_count: int :ivar status: Enumerates the possible values for the status of a Event Hub. Known values are: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", "Creating", "Deleting", - "Renaming", "Unknown". + "Renaming", and "Unknown". :vartype status: str or ~azure.mgmt.servicebus.v2017_04_01.models.EntityStatus :ivar capture_description: Properties of capture description. :vartype capture_description: ~azure.mgmt.servicebus.v2017_04_01.models.CaptureDescription """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'partition_ids': {'readonly': True}, - 'created_at': {'readonly': True}, - 'updated_at': {'readonly': True}, - 'message_retention_in_days': {'maximum': 7, 'minimum': 1}, - 'partition_count': {'maximum': 32, 'minimum': 1}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "partition_ids": {"readonly": True}, + "created_at": {"readonly": True}, + "updated_at": {"readonly": True}, + "message_retention_in_days": {"maximum": 7, "minimum": 1}, + "partition_count": {"maximum": 32, "minimum": 1}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'partition_ids': {'key': 'properties.partitionIds', 'type': '[str]'}, - 'created_at': {'key': 'properties.createdAt', 'type': 'iso-8601'}, - 'updated_at': {'key': 'properties.updatedAt', 'type': 'iso-8601'}, - 'message_retention_in_days': {'key': 'properties.messageRetentionInDays', 'type': 'long'}, - 'partition_count': {'key': 'properties.partitionCount', 'type': 'long'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'capture_description': {'key': 'properties.captureDescription', 'type': 'CaptureDescription'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "partition_ids": {"key": "properties.partitionIds", "type": "[str]"}, + "created_at": {"key": "properties.createdAt", "type": "iso-8601"}, + "updated_at": {"key": "properties.updatedAt", "type": "iso-8601"}, + "message_retention_in_days": {"key": "properties.messageRetentionInDays", "type": "int"}, + "partition_count": {"key": "properties.partitionCount", "type": "int"}, + "status": {"key": "properties.status", "type": "str"}, + "capture_description": {"key": "properties.captureDescription", "type": "CaptureDescription"}, } def __init__( @@ -731,18 +694,18 @@ def __init__( """ :keyword message_retention_in_days: Number of days to retain the events for this Event Hub, value should be 1 to 7 days. - :paramtype message_retention_in_days: long + :paramtype message_retention_in_days: int :keyword partition_count: Number of partitions created for the Event Hub, allowed values are from 1 to 32 partitions. - :paramtype partition_count: long + :paramtype partition_count: int :keyword status: Enumerates the possible values for the status of a Event Hub. Known values are: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", "Creating", - "Deleting", "Renaming", "Unknown". + "Deleting", "Renaming", and "Unknown". :paramtype status: str or ~azure.mgmt.servicebus.v2017_04_01.models.EntityStatus :keyword capture_description: Properties of capture description. :paramtype capture_description: ~azure.mgmt.servicebus.v2017_04_01.models.CaptureDescription """ - super(Eventhub, self).__init__(**kwargs) + super().__init__(**kwargs) self.partition_ids = None self.created_at = None self.updated_at = None @@ -752,7 +715,7 @@ def __init__( self.capture_description = capture_description -class EventHubListResult(msrest.serialization.Model): +class EventHubListResult(_serialization.Model): """The result of the List EventHubs operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -765,70 +728,61 @@ class EventHubListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Eventhub]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Eventhub]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["_models.Eventhub"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Eventhub"]] = None, **kwargs): """ :keyword value: Result of the List EventHubs operation. :paramtype value: list[~azure.mgmt.servicebus.v2017_04_01.models.Eventhub] """ - super(EventHubListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class MessageCountDetails(msrest.serialization.Model): +class MessageCountDetails(_serialization.Model): """Message Count Details. Variables are only populated by the server, and will be ignored when sending a request. :ivar active_message_count: Number of active messages in the queue, topic, or subscription. - :vartype active_message_count: long + :vartype active_message_count: int :ivar dead_letter_message_count: Number of messages that are dead lettered. - :vartype dead_letter_message_count: long + :vartype dead_letter_message_count: int :ivar scheduled_message_count: Number of scheduled messages. - :vartype scheduled_message_count: long + :vartype scheduled_message_count: int :ivar transfer_message_count: Number of messages transferred to another queue, topic, or subscription. - :vartype transfer_message_count: long + :vartype transfer_message_count: int :ivar transfer_dead_letter_message_count: Number of messages transferred into dead letters. - :vartype transfer_dead_letter_message_count: long + :vartype transfer_dead_letter_message_count: int """ _validation = { - 'active_message_count': {'readonly': True}, - 'dead_letter_message_count': {'readonly': True}, - 'scheduled_message_count': {'readonly': True}, - 'transfer_message_count': {'readonly': True}, - 'transfer_dead_letter_message_count': {'readonly': True}, + "active_message_count": {"readonly": True}, + "dead_letter_message_count": {"readonly": True}, + "scheduled_message_count": {"readonly": True}, + "transfer_message_count": {"readonly": True}, + "transfer_dead_letter_message_count": {"readonly": True}, } _attribute_map = { - 'active_message_count': {'key': 'activeMessageCount', 'type': 'long'}, - 'dead_letter_message_count': {'key': 'deadLetterMessageCount', 'type': 'long'}, - 'scheduled_message_count': {'key': 'scheduledMessageCount', 'type': 'long'}, - 'transfer_message_count': {'key': 'transferMessageCount', 'type': 'long'}, - 'transfer_dead_letter_message_count': {'key': 'transferDeadLetterMessageCount', 'type': 'long'}, + "active_message_count": {"key": "activeMessageCount", "type": "int"}, + "dead_letter_message_count": {"key": "deadLetterMessageCount", "type": "int"}, + "scheduled_message_count": {"key": "scheduledMessageCount", "type": "int"}, + "transfer_message_count": {"key": "transferMessageCount", "type": "int"}, + "transfer_dead_letter_message_count": {"key": "transferDeadLetterMessageCount", "type": "int"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(MessageCountDetails, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.active_message_count = None self.dead_letter_message_count = None self.scheduled_message_count = None @@ -836,7 +790,7 @@ def __init__( self.transfer_dead_letter_message_count = None -class MigrationConfigListResult(msrest.serialization.Model): +class MigrationConfigListResult(_serialization.Model): """The result of the List migrationConfigurations operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -849,25 +803,20 @@ class MigrationConfigListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[MigrationConfigProperties]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[MigrationConfigProperties]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["_models.MigrationConfigProperties"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.MigrationConfigProperties"]] = None, **kwargs): """ :keyword value: List of Migration Configs. :paramtype value: list[~azure.mgmt.servicebus.v2017_04_01.models.MigrationConfigProperties] """ - super(MigrationConfigListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None @@ -886,7 +835,7 @@ class MigrationConfigProperties(Resource): :ivar provisioning_state: Provisioning state of Migration Configuration. :vartype provisioning_state: str :ivar pending_replication_operations_count: Number of entities pending to be replicated. - :vartype pending_replication_operations_count: long + :vartype pending_replication_operations_count: int :ivar target_namespace: Existing premium Namespace ARM Id name which has no entities, will be used for migration. :vartype target_namespace: str @@ -898,32 +847,26 @@ class MigrationConfigProperties(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'pending_replication_operations_count': {'readonly': True}, - 'migration_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "pending_replication_operations_count": {"readonly": True}, + "migration_state": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'pending_replication_operations_count': {'key': 'properties.pendingReplicationOperationsCount', 'type': 'long'}, - 'target_namespace': {'key': 'properties.targetNamespace', 'type': 'str'}, - 'post_migration_name': {'key': 'properties.postMigrationName', 'type': 'str'}, - 'migration_state': {'key': 'properties.migrationState', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "pending_replication_operations_count": {"key": "properties.pendingReplicationOperationsCount", "type": "int"}, + "target_namespace": {"key": "properties.targetNamespace", "type": "str"}, + "post_migration_name": {"key": "properties.postMigrationName", "type": "str"}, + "migration_state": {"key": "properties.migrationState", "type": "str"}, } - def __init__( - self, - *, - target_namespace: Optional[str] = None, - post_migration_name: Optional[str] = None, - **kwargs - ): + def __init__(self, *, target_namespace: Optional[str] = None, post_migration_name: Optional[str] = None, **kwargs): """ :keyword target_namespace: Existing premium Namespace ARM Id name which has no entities, will be used for migration. @@ -931,7 +874,7 @@ def __init__( :keyword post_migration_name: Name to access Standard Namespace after migration. :paramtype post_migration_name: str """ - super(MigrationConfigProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = None self.pending_replication_operations_count = None self.target_namespace = target_namespace @@ -950,7 +893,8 @@ class NetworkRuleSet(Resource): :vartype name: str :ivar type: Resource type. :vartype type: str - :ivar default_action: Default Action for Network Rule Set. Known values are: "Allow", "Deny". + :ivar default_action: Default Action for Network Rule Set. Known values are: "Allow" and + "Deny". :vartype default_action: str or ~azure.mgmt.servicebus.v2017_04_01.models.DefaultAction :ivar virtual_network_rules: List VirtualNetwork Rules. :vartype virtual_network_rules: @@ -960,18 +904,18 @@ class NetworkRuleSet(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'default_action': {'key': 'properties.defaultAction', 'type': 'str'}, - 'virtual_network_rules': {'key': 'properties.virtualNetworkRules', 'type': '[NWRuleSetVirtualNetworkRules]'}, - 'ip_rules': {'key': 'properties.ipRules', 'type': '[NWRuleSetIpRules]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "default_action": {"key": "properties.defaultAction", "type": "str"}, + "virtual_network_rules": {"key": "properties.virtualNetworkRules", "type": "[NWRuleSetVirtualNetworkRules]"}, + "ip_rules": {"key": "properties.ipRules", "type": "[NWRuleSetIpRules]"}, } def __init__( @@ -983,7 +927,7 @@ def __init__( **kwargs ): """ - :keyword default_action: Default Action for Network Rule Set. Known values are: "Allow", + :keyword default_action: Default Action for Network Rule Set. Known values are: "Allow" and "Deny". :paramtype default_action: str or ~azure.mgmt.servicebus.v2017_04_01.models.DefaultAction :keyword virtual_network_rules: List VirtualNetwork Rules. @@ -992,13 +936,13 @@ def __init__( :keyword ip_rules: List of IpRules. :paramtype ip_rules: list[~azure.mgmt.servicebus.v2017_04_01.models.NWRuleSetIpRules] """ - super(NetworkRuleSet, self).__init__(**kwargs) + super().__init__(**kwargs) self.default_action = default_action self.virtual_network_rules = virtual_network_rules self.ip_rules = ip_rules -class NetworkRuleSetListResult(msrest.serialization.Model): +class NetworkRuleSetListResult(_serialization.Model): """The response of the List NetworkRuleSet operation. :ivar value: Result of the List NetworkRuleSet operation. @@ -1009,16 +953,12 @@ class NetworkRuleSetListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[NetworkRuleSet]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[NetworkRuleSet]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["_models.NetworkRuleSet"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.NetworkRuleSet"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Result of the List NetworkRuleSet operation. @@ -1027,44 +967,40 @@ def __init__( list of NetworkRuleSet. :paramtype next_link: str """ - super(NetworkRuleSetListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class NWRuleSetIpRules(msrest.serialization.Model): +class NWRuleSetIpRules(_serialization.Model): """Description of NetWorkRuleSet - IpRules resource. :ivar ip_mask: IP Mask. :vartype ip_mask: str - :ivar action: The IP Filter Action. Known values are: "Allow". Default value: "Allow". + :ivar action: The IP Filter Action. "Allow" :vartype action: str or ~azure.mgmt.servicebus.v2017_04_01.models.NetworkRuleIPAction """ _attribute_map = { - 'ip_mask': {'key': 'ipMask', 'type': 'str'}, - 'action': {'key': 'action', 'type': 'str'}, + "ip_mask": {"key": "ipMask", "type": "str"}, + "action": {"key": "action", "type": "str"}, } def __init__( - self, - *, - ip_mask: Optional[str] = None, - action: Optional[Union[str, "_models.NetworkRuleIPAction"]] = "Allow", - **kwargs + self, *, ip_mask: Optional[str] = None, action: Union[str, "_models.NetworkRuleIPAction"] = "Allow", **kwargs ): """ :keyword ip_mask: IP Mask. :paramtype ip_mask: str - :keyword action: The IP Filter Action. Known values are: "Allow". Default value: "Allow". + :keyword action: The IP Filter Action. "Allow" :paramtype action: str or ~azure.mgmt.servicebus.v2017_04_01.models.NetworkRuleIPAction """ - super(NWRuleSetIpRules, self).__init__(**kwargs) + super().__init__(**kwargs) self.ip_mask = ip_mask self.action = action -class NWRuleSetVirtualNetworkRules(msrest.serialization.Model): +class NWRuleSetVirtualNetworkRules(_serialization.Model): """Description of VirtualNetworkRules - NetworkRules resource. :ivar subnet: Subnet properties. @@ -1075,8 +1011,8 @@ class NWRuleSetVirtualNetworkRules(msrest.serialization.Model): """ _attribute_map = { - 'subnet': {'key': 'subnet', 'type': 'Subnet'}, - 'ignore_missing_vnet_service_endpoint': {'key': 'ignoreMissingVnetServiceEndpoint', 'type': 'bool'}, + "subnet": {"key": "subnet", "type": "Subnet"}, + "ignore_missing_vnet_service_endpoint": {"key": "ignoreMissingVnetServiceEndpoint", "type": "bool"}, } def __init__( @@ -1093,12 +1029,12 @@ def __init__( VNet Service Endpoint. :paramtype ignore_missing_vnet_service_endpoint: bool """ - super(NWRuleSetVirtualNetworkRules, self).__init__(**kwargs) + super().__init__(**kwargs) self.subnet = subnet self.ignore_missing_vnet_service_endpoint = ignore_missing_vnet_service_endpoint -class Operation(msrest.serialization.Model): +class Operation(_serialization.Model): """A ServiceBus REST API operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -1110,30 +1046,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["_models.OperationDisplay"] = None, - **kwargs - ): + def __init__(self, *, display: Optional["_models.OperationDisplay"] = None, **kwargs): """ :keyword display: The object that represents the operation. :paramtype display: ~azure.mgmt.servicebus.v2017_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. @@ -1147,30 +1078,26 @@ 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 OperationListResult(msrest.serialization.Model): +class OperationListResult(_serialization.Model): """Result of the request to list ServiceBus 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. @@ -1183,22 +1110,18 @@ 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 @@ -1216,38 +1139,32 @@ class ResourceNamespacePatch(Resource): :vartype type: str :ivar location: Resource location. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"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}'}, + "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: Optional[str] = None, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, **kwargs): """ :keyword location: Resource location. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] """ - super(ResourceNamespacePatch, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.tags = tags @@ -1265,7 +1182,7 @@ class PremiumMessagingRegions(ResourceNamespacePatch): :vartype type: str :ivar location: Resource location. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar properties: :vartype properties: @@ -1273,18 +1190,18 @@ class PremiumMessagingRegions(ResourceNamespacePatch): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"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}'}, - 'properties': {'key': 'properties', 'type': 'PremiumMessagingRegionsProperties'}, + "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}"}, + "properties": {"key": "properties", "type": "PremiumMessagingRegionsProperties"}, } def __init__( @@ -1298,17 +1215,17 @@ def __init__( """ :keyword location: Resource location. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword properties: :paramtype properties: ~azure.mgmt.servicebus.v2017_04_01.models.PremiumMessagingRegionsProperties """ - super(PremiumMessagingRegions, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.properties = properties -class PremiumMessagingRegionsListResult(msrest.serialization.Model): +class PremiumMessagingRegionsListResult(_serialization.Model): """The response of the List PremiumMessagingRegions operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -1321,30 +1238,25 @@ class PremiumMessagingRegionsListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[PremiumMessagingRegions]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[PremiumMessagingRegions]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["_models.PremiumMessagingRegions"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.PremiumMessagingRegions"]] = None, **kwargs): """ :keyword value: Result of the List PremiumMessagingRegions type. :paramtype value: list[~azure.mgmt.servicebus.v2017_04_01.models.PremiumMessagingRegions] """ - super(PremiumMessagingRegionsListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class PremiumMessagingRegionsProperties(msrest.serialization.Model): +class PremiumMessagingRegionsProperties(_serialization.Model): """PremiumMessagingRegionsProperties. Variables are only populated by the server, and will be ignored when sending a request. @@ -1356,32 +1268,28 @@ class PremiumMessagingRegionsProperties(msrest.serialization.Model): """ _validation = { - 'code': {'readonly': True}, - 'full_name': {'readonly': True}, + "code": {"readonly": True}, + "full_name": {"readonly": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'full_name': {'key': 'fullName', 'type': 'str'}, + "code": {"key": "code", "type": "str"}, + "full_name": {"key": "fullName", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(PremiumMessagingRegionsProperties, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.code = None self.full_name = None -class RegenerateAccessKeyParameters(msrest.serialization.Model): +class RegenerateAccessKeyParameters(_serialization.Model): """Parameters supplied to the Regenerate Authorization Rule operation, specifies which key needs to be reset. All required parameters must be populated in order to send to Azure. - :ivar key_type: Required. The access key to regenerate. Known values are: "PrimaryKey", + :ivar key_type: The access key to regenerate. Required. Known values are: "PrimaryKey" and "SecondaryKey". :vartype key_type: str or ~azure.mgmt.servicebus.v2017_04_01.models.KeyType :ivar key: Optional, if the key value provided, is reset for KeyType value or autogenerate Key @@ -1390,30 +1298,24 @@ class RegenerateAccessKeyParameters(msrest.serialization.Model): """ _validation = { - 'key_type': {'required': True}, + "key_type": {"required": True}, } _attribute_map = { - 'key_type': {'key': 'keyType', 'type': 'str'}, - 'key': {'key': 'key', 'type': 'str'}, + "key_type": {"key": "keyType", "type": "str"}, + "key": {"key": "key", "type": "str"}, } - def __init__( - self, - *, - key_type: Union[str, "_models.KeyType"], - key: Optional[str] = None, - **kwargs - ): + def __init__(self, *, key_type: Union[str, "_models.KeyType"], key: Optional[str] = None, **kwargs): """ - :keyword key_type: Required. The access key to regenerate. Known values are: "PrimaryKey", + :keyword key_type: The access key to regenerate. Required. Known values are: "PrimaryKey" and "SecondaryKey". :paramtype key_type: str or ~azure.mgmt.servicebus.v2017_04_01.models.KeyType :keyword key: Optional, if the key value provided, is reset for KeyType value or autogenerate Key value set for keyType. :paramtype key: str """ - super(RegenerateAccessKeyParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_type = key_type self.key = key @@ -1433,7 +1335,7 @@ class Rule(Resource): message that have been matched by a filter expression. :vartype action: ~azure.mgmt.servicebus.v2017_04_01.models.Action :ivar filter_type: Filter type that is evaluated against a BrokeredMessage. Known values are: - "SqlFilter", "CorrelationFilter". + "SqlFilter" and "CorrelationFilter". :vartype filter_type: str or ~azure.mgmt.servicebus.v2017_04_01.models.FilterType :ivar sql_filter: Properties of sqlFilter. :vartype sql_filter: ~azure.mgmt.servicebus.v2017_04_01.models.SqlFilter @@ -1442,19 +1344,19 @@ class Rule(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'action': {'key': 'properties.action', 'type': 'Action'}, - 'filter_type': {'key': 'properties.filterType', 'type': 'str'}, - 'sql_filter': {'key': 'properties.sqlFilter', 'type': 'SqlFilter'}, - 'correlation_filter': {'key': 'properties.correlationFilter', 'type': 'CorrelationFilter'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "action": {"key": "properties.action", "type": "Action"}, + "filter_type": {"key": "properties.filterType", "type": "str"}, + "sql_filter": {"key": "properties.sqlFilter", "type": "SqlFilter"}, + "correlation_filter": {"key": "properties.correlationFilter", "type": "CorrelationFilter"}, } def __init__( @@ -1471,21 +1373,21 @@ def __init__( message that have been matched by a filter expression. :paramtype action: ~azure.mgmt.servicebus.v2017_04_01.models.Action :keyword filter_type: Filter type that is evaluated against a BrokeredMessage. Known values - are: "SqlFilter", "CorrelationFilter". + are: "SqlFilter" and "CorrelationFilter". :paramtype filter_type: str or ~azure.mgmt.servicebus.v2017_04_01.models.FilterType :keyword sql_filter: Properties of sqlFilter. :paramtype sql_filter: ~azure.mgmt.servicebus.v2017_04_01.models.SqlFilter :keyword correlation_filter: Properties of correlationFilter. :paramtype correlation_filter: ~azure.mgmt.servicebus.v2017_04_01.models.CorrelationFilter """ - super(Rule, self).__init__(**kwargs) + super().__init__(**kwargs) self.action = action self.filter_type = filter_type self.sql_filter = sql_filter self.correlation_filter = correlation_filter -class RuleListResult(msrest.serialization.Model): +class RuleListResult(_serialization.Model): """The response of the List rule operation. :ivar value: Result of the List Rules operation. @@ -1496,17 +1398,11 @@ class RuleListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Rule]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Rule]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["_models.Rule"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Rule"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: Result of the List Rules operation. :paramtype value: list[~azure.mgmt.servicebus.v2017_04_01.models.Rule] @@ -1514,7 +1410,7 @@ def __init__( list of rules. :paramtype next_link: str """ - super(RuleListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link @@ -1535,33 +1431,28 @@ class SBAuthorizationRule(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'rights': {'key': 'properties.rights', 'type': '[str]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "rights": {"key": "properties.rights", "type": "[str]"}, } - def __init__( - self, - *, - rights: Optional[List[Union[str, "_models.AccessRights"]]] = None, - **kwargs - ): + def __init__(self, *, rights: Optional[List[Union[str, "_models.AccessRights"]]] = None, **kwargs): """ :keyword rights: The rights associated with the rule. :paramtype rights: list[str or ~azure.mgmt.servicebus.v2017_04_01.models.AccessRights] """ - super(SBAuthorizationRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.rights = rights -class SBAuthorizationRuleListResult(msrest.serialization.Model): +class SBAuthorizationRuleListResult(_serialization.Model): """The response to the List Namespace operation. :ivar value: Result of the List Authorization Rules operation. @@ -1572,16 +1463,12 @@ class SBAuthorizationRuleListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[SBAuthorizationRule]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SBAuthorizationRule]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["_models.SBAuthorizationRule"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.SBAuthorizationRule"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Result of the List Authorization Rules operation. @@ -1590,7 +1477,7 @@ def __init__( list of Authorization Rules. :paramtype next_link: str """ - super(SBAuthorizationRuleListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link @@ -1608,46 +1495,40 @@ class TrackedResource(Resource): :vartype name: str :ivar type: Resource type. :vartype type: str - :ivar location: Required. The Geo-location where the resource lives. + :ivar location: The Geo-location where the resource lives. Required. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "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 Geo-location where the resource lives. + :keyword location: The Geo-location where the resource lives. Required. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] """ - super(TrackedResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.tags = tags -class SBNamespace(TrackedResource): +class SBNamespace(TrackedResource): # pylint: disable=too-many-instance-attributes """Description of a namespace resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -1660,9 +1541,9 @@ class SBNamespace(TrackedResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :ivar location: Required. The Geo-location where the resource lives. + :ivar location: The Geo-location where the resource lives. Required. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar sku: Properties of Sku. :vartype sku: ~azure.mgmt.servicebus.v2017_04_01.models.SBSku @@ -1679,48 +1560,43 @@ class SBNamespace(TrackedResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'provisioning_state': {'readonly': True}, - 'created_at': {'readonly': True}, - 'updated_at': {'readonly': True}, - 'service_bus_endpoint': {'readonly': True}, - 'metric_id': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "provisioning_state": {"readonly": True}, + "created_at": {"readonly": True}, + "updated_at": {"readonly": True}, + "service_bus_endpoint": {"readonly": True}, + "metric_id": {"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}'}, - 'sku': {'key': 'sku', 'type': 'SBSku'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'created_at': {'key': 'properties.createdAt', 'type': 'iso-8601'}, - 'updated_at': {'key': 'properties.updatedAt', 'type': 'iso-8601'}, - 'service_bus_endpoint': {'key': 'properties.serviceBusEndpoint', 'type': 'str'}, - 'metric_id': {'key': 'properties.metricId', '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}"}, + "sku": {"key": "sku", "type": "SBSku"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "created_at": {"key": "properties.createdAt", "type": "iso-8601"}, + "updated_at": {"key": "properties.updatedAt", "type": "iso-8601"}, + "service_bus_endpoint": {"key": "properties.serviceBusEndpoint", "type": "str"}, + "metric_id": {"key": "properties.metricId", "type": "str"}, } def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - sku: Optional["_models.SBSku"] = None, - **kwargs + self, *, location: str, tags: Optional[Dict[str, str]] = None, sku: Optional["_models.SBSku"] = None, **kwargs ): """ - :keyword location: Required. The Geo-location where the resource lives. + :keyword location: The Geo-location where the resource lives. Required. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword sku: Properties of Sku. :paramtype sku: ~azure.mgmt.servicebus.v2017_04_01.models.SBSku """ - super(SBNamespace, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.sku = sku self.provisioning_state = None self.created_at = None @@ -1729,7 +1605,7 @@ def __init__( self.metric_id = None -class SBNamespaceListResult(msrest.serialization.Model): +class SBNamespaceListResult(_serialization.Model): """The response of the List Namespace operation. :ivar value: Result of the List Namespace operation. @@ -1740,16 +1616,12 @@ class SBNamespaceListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[SBNamespace]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SBNamespace]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["_models.SBNamespace"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.SBNamespace"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Result of the List Namespace operation. @@ -1758,46 +1630,41 @@ def __init__( list of Namespaces. :paramtype next_link: str """ - super(SBNamespaceListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class SBNamespaceMigrate(msrest.serialization.Model): +class SBNamespaceMigrate(_serialization.Model): """Namespace Migrate Object. All required parameters must be populated in order to send to Azure. - :ivar target_namespace_type: Required. Type of namespaces. Known values are: "Messaging", - "NotificationHub", "Mixed", "EventHub", "Relay". + :ivar target_namespace_type: Type of namespaces. Required. Known values are: "Messaging", + "NotificationHub", "Mixed", "EventHub", and "Relay". :vartype target_namespace_type: str or ~azure.mgmt.servicebus.v2017_04_01.models.NameSpaceType """ _validation = { - 'target_namespace_type': {'required': True}, + "target_namespace_type": {"required": True}, } _attribute_map = { - 'target_namespace_type': {'key': 'targetNamespaceType', 'type': 'str'}, + "target_namespace_type": {"key": "targetNamespaceType", "type": "str"}, } - def __init__( - self, - *, - target_namespace_type: Union[str, "_models.NameSpaceType"], - **kwargs - ): + def __init__(self, *, target_namespace_type: Union[str, "_models.NameSpaceType"], **kwargs): """ - :keyword target_namespace_type: Required. Type of namespaces. Known values are: "Messaging", - "NotificationHub", "Mixed", "EventHub", "Relay". + :keyword target_namespace_type: Type of namespaces. Required. Known values are: "Messaging", + "NotificationHub", "Mixed", "EventHub", and "Relay". :paramtype target_namespace_type: str or ~azure.mgmt.servicebus.v2017_04_01.models.NameSpaceType """ - super(SBNamespaceMigrate, self).__init__(**kwargs) + super().__init__(**kwargs) self.target_namespace_type = target_namespace_type -class SBNamespaceUpdateParameters(ResourceNamespacePatch): +class SBNamespaceUpdateParameters(ResourceNamespacePatch): # pylint: disable=too-many-instance-attributes """Description of a namespace resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -1810,7 +1677,7 @@ class SBNamespaceUpdateParameters(ResourceNamespacePatch): :vartype type: str :ivar location: Resource location. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar sku: Properties of Sku. :vartype sku: ~azure.mgmt.servicebus.v2017_04_01.models.SBSku @@ -1827,28 +1694,28 @@ class SBNamespaceUpdateParameters(ResourceNamespacePatch): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'created_at': {'readonly': True}, - 'updated_at': {'readonly': True}, - 'service_bus_endpoint': {'readonly': True}, - 'metric_id': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "created_at": {"readonly": True}, + "updated_at": {"readonly": True}, + "service_bus_endpoint": {"readonly": True}, + "metric_id": {"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}'}, - 'sku': {'key': 'sku', 'type': 'SBSku'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'created_at': {'key': 'properties.createdAt', 'type': 'iso-8601'}, - 'updated_at': {'key': 'properties.updatedAt', 'type': 'iso-8601'}, - 'service_bus_endpoint': {'key': 'properties.serviceBusEndpoint', 'type': 'str'}, - 'metric_id': {'key': 'properties.metricId', '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}"}, + "sku": {"key": "sku", "type": "SBSku"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "created_at": {"key": "properties.createdAt", "type": "iso-8601"}, + "updated_at": {"key": "properties.updatedAt", "type": "iso-8601"}, + "service_bus_endpoint": {"key": "properties.serviceBusEndpoint", "type": "str"}, + "metric_id": {"key": "properties.metricId", "type": "str"}, } def __init__( @@ -1862,12 +1729,12 @@ def __init__( """ :keyword location: Resource location. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword sku: Properties of Sku. :paramtype sku: ~azure.mgmt.servicebus.v2017_04_01.models.SBSku """ - super(SBNamespaceUpdateParameters, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.sku = sku self.provisioning_state = None self.created_at = None @@ -1876,7 +1743,7 @@ def __init__( self.metric_id = None -class SBQueue(Resource): +class SBQueue(Resource): # pylint: disable=too-many-instance-attributes """Description of queue Resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -1897,9 +1764,9 @@ class SBQueue(Resource): to this queue. :vartype accessed_at: ~datetime.datetime :ivar size_in_bytes: The size of the queue, in bytes. - :vartype size_in_bytes: long + :vartype size_in_bytes: int :ivar message_count: The number of messages in the queue. - :vartype message_count: long + :vartype message_count: int :ivar lock_duration: ISO 8601 timespan duration of a peek-lock; that is, the amount of time that the message is locked for other receivers. The maximum value for LockDuration is 5 minutes; the default value is 1 minute. @@ -1928,7 +1795,7 @@ class SBQueue(Resource): :vartype max_delivery_count: int :ivar status: Enumerates the possible values for the status of a messaging entity. Known values are: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", "Creating", - "Deleting", "Renaming", "Unknown". + "Deleting", "Renaming", and "Unknown". :vartype status: str or ~azure.mgmt.servicebus.v2017_04_01.models.EntityStatus :ivar enable_batched_operations: Value that indicates whether server-side batched operations are enabled. @@ -1949,45 +1816,48 @@ class SBQueue(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'count_details': {'readonly': True}, - 'created_at': {'readonly': True}, - 'updated_at': {'readonly': True}, - 'accessed_at': {'readonly': True}, - 'size_in_bytes': {'readonly': True}, - 'message_count': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "count_details": {"readonly": True}, + "created_at": {"readonly": True}, + "updated_at": {"readonly": True}, + "accessed_at": {"readonly": True}, + "size_in_bytes": {"readonly": True}, + "message_count": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'count_details': {'key': 'properties.countDetails', 'type': 'MessageCountDetails'}, - 'created_at': {'key': 'properties.createdAt', 'type': 'iso-8601'}, - 'updated_at': {'key': 'properties.updatedAt', 'type': 'iso-8601'}, - 'accessed_at': {'key': 'properties.accessedAt', 'type': 'iso-8601'}, - 'size_in_bytes': {'key': 'properties.sizeInBytes', 'type': 'long'}, - 'message_count': {'key': 'properties.messageCount', 'type': 'long'}, - 'lock_duration': {'key': 'properties.lockDuration', 'type': 'duration'}, - 'max_size_in_megabytes': {'key': 'properties.maxSizeInMegabytes', 'type': 'int'}, - 'requires_duplicate_detection': {'key': 'properties.requiresDuplicateDetection', 'type': 'bool'}, - 'requires_session': {'key': 'properties.requiresSession', 'type': 'bool'}, - 'default_message_time_to_live': {'key': 'properties.defaultMessageTimeToLive', 'type': 'duration'}, - 'dead_lettering_on_message_expiration': {'key': 'properties.deadLetteringOnMessageExpiration', 'type': 'bool'}, - 'duplicate_detection_history_time_window': {'key': 'properties.duplicateDetectionHistoryTimeWindow', 'type': 'duration'}, - 'max_delivery_count': {'key': 'properties.maxDeliveryCount', 'type': 'int'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'enable_batched_operations': {'key': 'properties.enableBatchedOperations', 'type': 'bool'}, - 'auto_delete_on_idle': {'key': 'properties.autoDeleteOnIdle', 'type': 'duration'}, - 'enable_partitioning': {'key': 'properties.enablePartitioning', 'type': 'bool'}, - 'enable_express': {'key': 'properties.enableExpress', 'type': 'bool'}, - 'forward_to': {'key': 'properties.forwardTo', 'type': 'str'}, - 'forward_dead_lettered_messages_to': {'key': 'properties.forwardDeadLetteredMessagesTo', 'type': 'str'}, - } - - def __init__( + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "count_details": {"key": "properties.countDetails", "type": "MessageCountDetails"}, + "created_at": {"key": "properties.createdAt", "type": "iso-8601"}, + "updated_at": {"key": "properties.updatedAt", "type": "iso-8601"}, + "accessed_at": {"key": "properties.accessedAt", "type": "iso-8601"}, + "size_in_bytes": {"key": "properties.sizeInBytes", "type": "int"}, + "message_count": {"key": "properties.messageCount", "type": "int"}, + "lock_duration": {"key": "properties.lockDuration", "type": "duration"}, + "max_size_in_megabytes": {"key": "properties.maxSizeInMegabytes", "type": "int"}, + "requires_duplicate_detection": {"key": "properties.requiresDuplicateDetection", "type": "bool"}, + "requires_session": {"key": "properties.requiresSession", "type": "bool"}, + "default_message_time_to_live": {"key": "properties.defaultMessageTimeToLive", "type": "duration"}, + "dead_lettering_on_message_expiration": {"key": "properties.deadLetteringOnMessageExpiration", "type": "bool"}, + "duplicate_detection_history_time_window": { + "key": "properties.duplicateDetectionHistoryTimeWindow", + "type": "duration", + }, + "max_delivery_count": {"key": "properties.maxDeliveryCount", "type": "int"}, + "status": {"key": "properties.status", "type": "str"}, + "enable_batched_operations": {"key": "properties.enableBatchedOperations", "type": "bool"}, + "auto_delete_on_idle": {"key": "properties.autoDeleteOnIdle", "type": "duration"}, + "enable_partitioning": {"key": "properties.enablePartitioning", "type": "bool"}, + "enable_express": {"key": "properties.enableExpress", "type": "bool"}, + "forward_to": {"key": "properties.forwardTo", "type": "str"}, + "forward_dead_lettered_messages_to": {"key": "properties.forwardDeadLetteredMessagesTo", "type": "str"}, + } + + def __init__( # pylint: disable=too-many-locals self, *, lock_duration: Optional[datetime.timedelta] = None, @@ -2036,7 +1906,7 @@ def __init__( :paramtype max_delivery_count: int :keyword status: Enumerates the possible values for the status of a messaging entity. Known values are: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", "Creating", - "Deleting", "Renaming", "Unknown". + "Deleting", "Renaming", and "Unknown". :paramtype status: str or ~azure.mgmt.servicebus.v2017_04_01.models.EntityStatus :keyword enable_batched_operations: Value that indicates whether server-side batched operations are enabled. @@ -2056,7 +1926,7 @@ def __init__( message. :paramtype forward_dead_lettered_messages_to: str """ - super(SBQueue, self).__init__(**kwargs) + super().__init__(**kwargs) self.count_details = None self.created_at = None self.updated_at = None @@ -2080,7 +1950,7 @@ def __init__( self.forward_dead_lettered_messages_to = forward_dead_lettered_messages_to -class SBQueueListResult(msrest.serialization.Model): +class SBQueueListResult(_serialization.Model): """The response to the List Queues operation. :ivar value: Result of the List Queues operation. @@ -2091,17 +1961,11 @@ class SBQueueListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[SBQueue]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SBQueue]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["_models.SBQueue"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.SBQueue"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: Result of the List Queues operation. :paramtype value: list[~azure.mgmt.servicebus.v2017_04_01.models.SBQueue] @@ -2109,19 +1973,19 @@ def __init__( list of queues. :paramtype next_link: str """ - super(SBQueueListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class SBSku(msrest.serialization.Model): +class SBSku(_serialization.Model): """SKU of the namespace. All required parameters must be populated in order to send to Azure. - :ivar name: Required. Name of this SKU. Known values are: "Basic", "Standard", "Premium". + :ivar name: Name of this SKU. Required. Known values are: "Basic", "Standard", and "Premium". :vartype name: str or ~azure.mgmt.servicebus.v2017_04_01.models.SkuName - :ivar tier: The billing tier of this particular SKU. Known values are: "Basic", "Standard", + :ivar tier: The billing tier of this particular SKU. Known values are: "Basic", "Standard", and "Premium". :vartype tier: str or ~azure.mgmt.servicebus.v2017_04_01.models.SkuTier :ivar capacity: The specified messaging units for the tier. For Premium tier, capacity are 1,2 @@ -2130,13 +1994,13 @@ class SBSku(msrest.serialization.Model): """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'capacity': {'key': 'capacity', 'type': 'int'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "capacity": {"key": "capacity", "type": "int"}, } def __init__( @@ -2148,22 +2012,23 @@ def __init__( **kwargs ): """ - :keyword name: Required. Name of this SKU. Known values are: "Basic", "Standard", "Premium". + :keyword name: Name of this SKU. Required. Known values are: "Basic", "Standard", and + "Premium". :paramtype name: str or ~azure.mgmt.servicebus.v2017_04_01.models.SkuName :keyword tier: The billing tier of this particular SKU. Known values are: "Basic", "Standard", - "Premium". + and "Premium". :paramtype tier: str or ~azure.mgmt.servicebus.v2017_04_01.models.SkuTier :keyword capacity: The specified messaging units for the tier. For Premium tier, capacity are 1,2 and 4. :paramtype capacity: int """ - super(SBSku, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.tier = tier self.capacity = capacity -class SBSubscription(Resource): +class SBSubscription(Resource): # pylint: disable=too-many-instance-attributes """Description of subscription resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -2175,7 +2040,7 @@ class SBSubscription(Resource): :ivar type: Resource type. :vartype type: str :ivar message_count: Number of messages. - :vartype message_count: long + :vartype message_count: int :ivar created_at: Exact time the message was created. :vartype created_at: ~datetime.datetime :ivar accessed_at: Last time there was a receive request to this subscription. @@ -2206,7 +2071,7 @@ class SBSubscription(Resource): :vartype max_delivery_count: int :ivar status: Enumerates the possible values for the status of a messaging entity. Known values are: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", "Creating", - "Deleting", "Renaming", "Unknown". + "Deleting", "Renaming", and "Unknown". :vartype status: str or ~azure.mgmt.servicebus.v2017_04_01.models.EntityStatus :ivar enable_batched_operations: Value that indicates whether server-side batched operations are enabled. @@ -2221,37 +2086,43 @@ class SBSubscription(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'message_count': {'readonly': True}, - 'created_at': {'readonly': True}, - 'accessed_at': {'readonly': True}, - 'updated_at': {'readonly': True}, - 'count_details': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "message_count": {"readonly": True}, + "created_at": {"readonly": True}, + "accessed_at": {"readonly": True}, + "updated_at": {"readonly": True}, + "count_details": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'message_count': {'key': 'properties.messageCount', 'type': 'long'}, - 'created_at': {'key': 'properties.createdAt', 'type': 'iso-8601'}, - 'accessed_at': {'key': 'properties.accessedAt', 'type': 'iso-8601'}, - 'updated_at': {'key': 'properties.updatedAt', 'type': 'iso-8601'}, - 'count_details': {'key': 'properties.countDetails', 'type': 'MessageCountDetails'}, - 'lock_duration': {'key': 'properties.lockDuration', 'type': 'duration'}, - 'requires_session': {'key': 'properties.requiresSession', 'type': 'bool'}, - 'default_message_time_to_live': {'key': 'properties.defaultMessageTimeToLive', 'type': 'duration'}, - 'dead_lettering_on_filter_evaluation_exceptions': {'key': 'properties.deadLetteringOnFilterEvaluationExceptions', 'type': 'bool'}, - 'dead_lettering_on_message_expiration': {'key': 'properties.deadLetteringOnMessageExpiration', 'type': 'bool'}, - 'duplicate_detection_history_time_window': {'key': 'properties.duplicateDetectionHistoryTimeWindow', 'type': 'duration'}, - 'max_delivery_count': {'key': 'properties.maxDeliveryCount', 'type': 'int'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'enable_batched_operations': {'key': 'properties.enableBatchedOperations', 'type': 'bool'}, - 'auto_delete_on_idle': {'key': 'properties.autoDeleteOnIdle', 'type': 'duration'}, - 'forward_to': {'key': 'properties.forwardTo', 'type': 'str'}, - 'forward_dead_lettered_messages_to': {'key': 'properties.forwardDeadLetteredMessagesTo', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "message_count": {"key": "properties.messageCount", "type": "int"}, + "created_at": {"key": "properties.createdAt", "type": "iso-8601"}, + "accessed_at": {"key": "properties.accessedAt", "type": "iso-8601"}, + "updated_at": {"key": "properties.updatedAt", "type": "iso-8601"}, + "count_details": {"key": "properties.countDetails", "type": "MessageCountDetails"}, + "lock_duration": {"key": "properties.lockDuration", "type": "duration"}, + "requires_session": {"key": "properties.requiresSession", "type": "bool"}, + "default_message_time_to_live": {"key": "properties.defaultMessageTimeToLive", "type": "duration"}, + "dead_lettering_on_filter_evaluation_exceptions": { + "key": "properties.deadLetteringOnFilterEvaluationExceptions", + "type": "bool", + }, + "dead_lettering_on_message_expiration": {"key": "properties.deadLetteringOnMessageExpiration", "type": "bool"}, + "duplicate_detection_history_time_window": { + "key": "properties.duplicateDetectionHistoryTimeWindow", + "type": "duration", + }, + "max_delivery_count": {"key": "properties.maxDeliveryCount", "type": "int"}, + "status": {"key": "properties.status", "type": "str"}, + "enable_batched_operations": {"key": "properties.enableBatchedOperations", "type": "bool"}, + "auto_delete_on_idle": {"key": "properties.autoDeleteOnIdle", "type": "duration"}, + "forward_to": {"key": "properties.forwardTo", "type": "str"}, + "forward_dead_lettered_messages_to": {"key": "properties.forwardDeadLetteredMessagesTo", "type": "str"}, } def __init__( @@ -2294,7 +2165,7 @@ def __init__( :paramtype max_delivery_count: int :keyword status: Enumerates the possible values for the status of a messaging entity. Known values are: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", "Creating", - "Deleting", "Renaming", "Unknown". + "Deleting", "Renaming", and "Unknown". :paramtype status: str or ~azure.mgmt.servicebus.v2017_04_01.models.EntityStatus :keyword enable_batched_operations: Value that indicates whether server-side batched operations are enabled. @@ -2308,7 +2179,7 @@ def __init__( message. :paramtype forward_dead_lettered_messages_to: str """ - super(SBSubscription, self).__init__(**kwargs) + super().__init__(**kwargs) self.message_count = None self.created_at = None self.accessed_at = None @@ -2328,7 +2199,7 @@ def __init__( self.forward_dead_lettered_messages_to = forward_dead_lettered_messages_to -class SBSubscriptionListResult(msrest.serialization.Model): +class SBSubscriptionListResult(_serialization.Model): """The response to the List Subscriptions operation. :ivar value: Result of the List Subscriptions operation. @@ -2339,16 +2210,12 @@ class SBSubscriptionListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[SBSubscription]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SBSubscription]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["_models.SBSubscription"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.SBSubscription"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Result of the List Subscriptions operation. @@ -2357,12 +2224,12 @@ def __init__( list of subscriptions. :paramtype next_link: str """ - super(SBSubscriptionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class SBTopic(Resource): +class SBTopic(Resource): # pylint: disable=too-many-instance-attributes """Description of topic resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -2374,7 +2241,7 @@ class SBTopic(Resource): :ivar type: Resource type. :vartype type: str :ivar size_in_bytes: Size of the topic, in bytes. - :vartype size_in_bytes: long + :vartype size_in_bytes: int :ivar created_at: Exact time the message was created. :vartype created_at: ~datetime.datetime :ivar updated_at: The exact time the message was updated. @@ -2403,7 +2270,7 @@ class SBTopic(Resource): :vartype enable_batched_operations: bool :ivar status: Enumerates the possible values for the status of a messaging entity. Known values are: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", "Creating", - "Deleting", "Renaming", "Unknown". + "Deleting", "Renaming", and "Unknown". :vartype status: str or ~azure.mgmt.servicebus.v2017_04_01.models.EntityStatus :ivar support_ordering: Value that indicates whether the topic supports ordering. :vartype support_ordering: bool @@ -2419,37 +2286,40 @@ class SBTopic(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'size_in_bytes': {'readonly': True}, - 'created_at': {'readonly': True}, - 'updated_at': {'readonly': True}, - 'accessed_at': {'readonly': True}, - 'subscription_count': {'readonly': True}, - 'count_details': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "size_in_bytes": {"readonly": True}, + "created_at": {"readonly": True}, + "updated_at": {"readonly": True}, + "accessed_at": {"readonly": True}, + "subscription_count": {"readonly": True}, + "count_details": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'size_in_bytes': {'key': 'properties.sizeInBytes', 'type': 'long'}, - 'created_at': {'key': 'properties.createdAt', 'type': 'iso-8601'}, - 'updated_at': {'key': 'properties.updatedAt', 'type': 'iso-8601'}, - 'accessed_at': {'key': 'properties.accessedAt', 'type': 'iso-8601'}, - 'subscription_count': {'key': 'properties.subscriptionCount', 'type': 'int'}, - 'count_details': {'key': 'properties.countDetails', 'type': 'MessageCountDetails'}, - 'default_message_time_to_live': {'key': 'properties.defaultMessageTimeToLive', 'type': 'duration'}, - 'max_size_in_megabytes': {'key': 'properties.maxSizeInMegabytes', 'type': 'int'}, - 'requires_duplicate_detection': {'key': 'properties.requiresDuplicateDetection', 'type': 'bool'}, - 'duplicate_detection_history_time_window': {'key': 'properties.duplicateDetectionHistoryTimeWindow', 'type': 'duration'}, - 'enable_batched_operations': {'key': 'properties.enableBatchedOperations', 'type': 'bool'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'support_ordering': {'key': 'properties.supportOrdering', 'type': 'bool'}, - 'auto_delete_on_idle': {'key': 'properties.autoDeleteOnIdle', 'type': 'duration'}, - 'enable_partitioning': {'key': 'properties.enablePartitioning', 'type': 'bool'}, - 'enable_express': {'key': 'properties.enableExpress', 'type': 'bool'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "size_in_bytes": {"key": "properties.sizeInBytes", "type": "int"}, + "created_at": {"key": "properties.createdAt", "type": "iso-8601"}, + "updated_at": {"key": "properties.updatedAt", "type": "iso-8601"}, + "accessed_at": {"key": "properties.accessedAt", "type": "iso-8601"}, + "subscription_count": {"key": "properties.subscriptionCount", "type": "int"}, + "count_details": {"key": "properties.countDetails", "type": "MessageCountDetails"}, + "default_message_time_to_live": {"key": "properties.defaultMessageTimeToLive", "type": "duration"}, + "max_size_in_megabytes": {"key": "properties.maxSizeInMegabytes", "type": "int"}, + "requires_duplicate_detection": {"key": "properties.requiresDuplicateDetection", "type": "bool"}, + "duplicate_detection_history_time_window": { + "key": "properties.duplicateDetectionHistoryTimeWindow", + "type": "duration", + }, + "enable_batched_operations": {"key": "properties.enableBatchedOperations", "type": "bool"}, + "status": {"key": "properties.status", "type": "str"}, + "support_ordering": {"key": "properties.supportOrdering", "type": "bool"}, + "auto_delete_on_idle": {"key": "properties.autoDeleteOnIdle", "type": "duration"}, + "enable_partitioning": {"key": "properties.enablePartitioning", "type": "bool"}, + "enable_express": {"key": "properties.enableExpress", "type": "bool"}, } def __init__( @@ -2486,7 +2356,7 @@ def __init__( :paramtype enable_batched_operations: bool :keyword status: Enumerates the possible values for the status of a messaging entity. Known values are: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", "Creating", - "Deleting", "Renaming", "Unknown". + "Deleting", "Renaming", and "Unknown". :paramtype status: str or ~azure.mgmt.servicebus.v2017_04_01.models.EntityStatus :keyword support_ordering: Value that indicates whether the topic supports ordering. :paramtype support_ordering: bool @@ -2500,7 +2370,7 @@ def __init__( topic holds a message in memory temporarily before writing it to persistent storage. :paramtype enable_express: bool """ - super(SBTopic, self).__init__(**kwargs) + super().__init__(**kwargs) self.size_in_bytes = None self.created_at = None self.updated_at = None @@ -2519,7 +2389,7 @@ def __init__( self.enable_express = enable_express -class SBTopicListResult(msrest.serialization.Model): +class SBTopicListResult(_serialization.Model): """The response to the List Topics operation. :ivar value: Result of the List Topics operation. @@ -2530,17 +2400,11 @@ class SBTopicListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[SBTopic]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SBTopic]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["_models.SBTopic"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.SBTopic"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: Result of the List Topics operation. :paramtype value: list[~azure.mgmt.servicebus.v2017_04_01.models.SBTopic] @@ -2548,12 +2412,12 @@ def __init__( list of topics. :paramtype next_link: str """ - super(SBTopicListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class SqlFilter(msrest.serialization.Model): +class SqlFilter(_serialization.Model): """Represents a filter which is a composition of an expression and an action that is executed in the pub/sub pipeline. :ivar sql_expression: The SQL expression. e.g. MyProperty='ABC'. @@ -2567,21 +2431,21 @@ class SqlFilter(msrest.serialization.Model): """ _validation = { - 'compatibility_level': {'maximum': 20, 'minimum': 20}, + "compatibility_level": {"maximum": 20, "minimum": 20}, } _attribute_map = { - 'sql_expression': {'key': 'sqlExpression', 'type': 'str'}, - 'compatibility_level': {'key': 'compatibilityLevel', 'type': 'int'}, - 'requires_preprocessing': {'key': 'requiresPreprocessing', 'type': 'bool'}, + "sql_expression": {"key": "sqlExpression", "type": "str"}, + "compatibility_level": {"key": "compatibilityLevel", "type": "int"}, + "requires_preprocessing": {"key": "requiresPreprocessing", "type": "bool"}, } def __init__( self, *, sql_expression: Optional[str] = None, - compatibility_level: Optional[int] = 20, - requires_preprocessing: Optional[bool] = True, + compatibility_level: int = 20, + requires_preprocessing: bool = True, **kwargs ): """ @@ -2594,7 +2458,7 @@ def __init__( preprocessing. :paramtype requires_preprocessing: bool """ - super(SqlFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.sql_expression = sql_expression self.compatibility_level = compatibility_level self.requires_preprocessing = requires_preprocessing @@ -2614,9 +2478,9 @@ class SqlRuleAction(Action): """ _attribute_map = { - 'sql_expression': {'key': 'sqlExpression', 'type': 'str'}, - 'compatibility_level': {'key': 'compatibilityLevel', 'type': 'int'}, - 'requires_preprocessing': {'key': 'requiresPreprocessing', 'type': 'bool'}, + "sql_expression": {"key": "sqlExpression", "type": "str"}, + "compatibility_level": {"key": "compatibilityLevel", "type": "int"}, + "requires_preprocessing": {"key": "requiresPreprocessing", "type": "bool"}, } def __init__( @@ -2624,7 +2488,7 @@ def __init__( *, sql_expression: Optional[str] = None, compatibility_level: Optional[int] = None, - requires_preprocessing: Optional[bool] = True, + requires_preprocessing: bool = True, **kwargs ): """ @@ -2637,35 +2501,35 @@ def __init__( preprocessing. :paramtype requires_preprocessing: bool """ - super(SqlRuleAction, self).__init__(sql_expression=sql_expression, compatibility_level=compatibility_level, requires_preprocessing=requires_preprocessing, **kwargs) + super().__init__( + sql_expression=sql_expression, + compatibility_level=compatibility_level, + requires_preprocessing=requires_preprocessing, + **kwargs + ) -class Subnet(msrest.serialization.Model): +class Subnet(_serialization.Model): """Properties supplied for Subnet. All required parameters must be populated in order to send to Azure. - :ivar id: Required. Resource ID of Virtual Network Subnet. + :ivar id: Resource ID of Virtual Network Subnet. Required. :vartype id: str """ _validation = { - 'id': {'required': True}, + "id": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - *, - id: str, - **kwargs - ): + def __init__(self, *, id: str, **kwargs): # pylint: disable=redefined-builtin """ - :keyword id: Required. Resource ID of Virtual Network Subnet. + :keyword id: Resource ID of Virtual Network Subnet. Required. :paramtype id: str """ - super(Subnet, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/models/_patch.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/models/_patch.py index 0ad201a8c586e..f7dd32510333d 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/models/_patch.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/models/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/models/_service_bus_management_client_enums.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/models/_service_bus_management_client_enums.py index c1bc966d44442..ccd7445092c7d 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/models/_service_bus_management_client_enums.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/models/_service_bus_management_client_enums.py @@ -11,28 +11,29 @@ class AccessRights(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """AccessRights.""" MANAGE = "Manage" SEND = "Send" LISTEN = "Listen" + class DefaultAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Default Action for Network Rule Set - """ + """Default Action for Network Rule Set.""" ALLOW = "Allow" DENY = "Deny" + class EncodingCaptureDescription(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Enumerates the possible values for the encoding format of capture description. - """ + """Enumerates the possible values for the encoding format of capture description.""" AVRO = "Avro" AVRO_DEFLATE = "AvroDeflate" + class EntityStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Entity status. - """ + """Entity status.""" ACTIVE = "Active" DISABLED = "Disabled" @@ -44,27 +45,29 @@ class EntityStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): RENAMING = "Renaming" UNKNOWN = "Unknown" + class FilterType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Rule filter types - """ + """Rule filter types.""" SQL_FILTER = "SqlFilter" CORRELATION_FILTER = "CorrelationFilter" + class KeyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The access key to regenerate. - """ + """The access key to regenerate.""" PRIMARY_KEY = "PrimaryKey" SECONDARY_KEY = "SecondaryKey" + class MigrationConfigurationName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """MigrationConfigurationName.""" _DEFAULT = "$default" + class NameSpaceType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Type of namespaces - """ + """Type of namespaces.""" MESSAGING = "Messaging" NOTIFICATION_HUB = "NotificationHub" @@ -72,49 +75,51 @@ class NameSpaceType(str, Enum, metaclass=CaseInsensitiveEnumMeta): EVENT_HUB = "EventHub" RELAY = "Relay" + class NetworkRuleIPAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The IP Filter Action - """ + """The IP Filter Action.""" ALLOW = "Allow" + class ProvisioningStateDR(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Provisioning state of the Alias(Disaster Recovery configuration) - possible values 'Accepted' - or 'Succeeded' or 'Failed' + or 'Succeeded' or 'Failed'. """ ACCEPTED = "Accepted" SUCCEEDED = "Succeeded" FAILED = "Failed" + class RoleDisasterRecovery(str, Enum, metaclass=CaseInsensitiveEnumMeta): """role of namespace in GEO DR - possible values 'Primary' or 'PrimaryNotReplicating' or - 'Secondary' + 'Secondary'. """ PRIMARY = "Primary" PRIMARY_NOT_REPLICATING = "PrimaryNotReplicating" SECONDARY = "Secondary" + class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Name of this SKU. - """ + """Name of this SKU.""" BASIC = "Basic" STANDARD = "Standard" PREMIUM = "Premium" + class SkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The billing tier of this particular SKU. - """ + """The billing tier of this particular SKU.""" BASIC = "Basic" STANDARD = "Standard" PREMIUM = "Premium" + class UnavailableReason(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the reason for the unavailability of the service. - """ + """Specifies the reason for the unavailability of the service.""" NONE = "None" INVALID_NAME = "InvalidName" diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/__init__.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/__init__.py index 02badefef72e4..dbb5c8284b01c 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/__init__.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/__init__.py @@ -19,20 +19,21 @@ from ._subscriptions_operations import SubscriptionsOperations from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'NamespacesOperations', - 'QueuesOperations', - 'TopicsOperations', - 'DisasterRecoveryConfigsOperations', - 'EventHubsOperations', - 'MigrationConfigsOperations', - 'Operations', - 'PremiumMessagingRegionsOperations', - 'RulesOperations', - 'RegionsOperations', - 'SubscriptionsOperations', + "NamespacesOperations", + "QueuesOperations", + "TopicsOperations", + "DisasterRecoveryConfigsOperations", + "EventHubsOperations", + "MigrationConfigsOperations", + "Operations", + "PremiumMessagingRegionsOperations", + "RulesOperations", + "RegionsOperations", + "SubscriptionsOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/_disaster_recovery_configs_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/_disaster_recovery_configs_operations.py index f46ad70688522..0098d190eeb42 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/_disaster_recovery_configs_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/_disaster_recovery_configs_operations.py @@ -6,11 +6,18 @@ # 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 msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,335 +27,294 @@ 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') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_check_name_availability_request( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - *, - json: Optional[_models.CheckNameAvailability] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_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-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: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/CheckNameAvailability") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/CheckNameAvailability", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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') + _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, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_request( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_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-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( - resource_group_name: str, - namespace_name: str, - alias: str, - subscription_id: str, - *, - json: Optional[_models.ArmDisasterRecovery] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_name: str, alias: 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-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: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "alias": _SERIALIZER.url("alias", alias, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "alias": _SERIALIZER.url("alias", alias, "str", max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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') + _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, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - namespace_name: str, - alias: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, alias: 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-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "alias": _SERIALIZER.url("alias", alias, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "alias": _SERIALIZER.url("alias", alias, "str", max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - namespace_name: str, - alias: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, alias: 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-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "alias": _SERIALIZER.url("alias", alias, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "alias": _SERIALIZER.url("alias", alias, "str", max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_break_pairing_request( - resource_group_name: str, - namespace_name: str, - alias: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, alias: 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-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/breakPairing") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/breakPairing", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "alias": _SERIALIZER.url("alias", alias, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "alias": _SERIALIZER.url("alias", alias, "str", max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_fail_over_request( - resource_group_name: str, - namespace_name: str, - alias: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, alias: 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-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/failover") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/failover", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "alias": _SERIALIZER.url("alias", alias, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "alias": _SERIALIZER.url("alias", alias, "str", max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_authorization_rules_request( - resource_group_name: str, - namespace_name: str, - alias: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, alias: 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-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/AuthorizationRules") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/AuthorizationRules", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "alias": _SERIALIZER.url("alias", alias, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "alias": _SERIALIZER.url("alias", alias, "str", max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_authorization_rule_request( @@ -362,34 +328,35 @@ def build_get_authorization_rule_request( _headers = case_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-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/AuthorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/AuthorizationRules/{authorizationRuleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "alias": _SERIALIZER.url("alias", alias, 'str', max_length=50, min_length=1), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "alias": _SERIALIZER.url("alias", alias, "str", max_length=50, min_length=1), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_keys_request( @@ -403,34 +370,36 @@ def build_list_keys_request( _headers = case_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-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/AuthorizationRules/{authorizationRuleName}/listKeys") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/AuthorizationRules/{authorizationRuleName}/listKeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "alias": _SERIALIZER.url("alias", alias, 'str', max_length=50, min_length=1), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "alias": _SERIALIZER.url("alias", alias, "str", max_length=50, min_length=1), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class DisasterRecoveryConfigsOperations: """ @@ -451,41 +420,107 @@ def __init__(self, *args, **kwargs): 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 + @overload def check_name_availability( self, resource_group_name: str, namespace_name: str, parameters: _models.CheckNameAvailability, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Check the give namespace name availability. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: Parameters to check availability of the given namespace name. + :param parameters: Parameters to check availability of the given namespace name. Required. :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.CheckNameAvailability + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckNameAvailabilityResult, or the result of cls(response) + :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.CheckNameAvailabilityResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters to check availability of the given namespace name. Required. + :type 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: CheckNameAvailabilityResult or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_name_availability( + self, + resource_group_name: str, + namespace_name: str, + parameters: Union[_models.CheckNameAvailability, IO], + **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters to check availability of the given namespace name. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.CheckNameAvailability 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: CheckNameAvailabilityResult or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.CheckNameAvailabilityResult] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CheckNameAvailabilityResult] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'CheckNameAvailability') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "CheckNameAvailability") request = build_check_name_availability_request( resource_group_name=resource_group_name, @@ -494,18 +529,18 @@ def check_name_availability( 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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -513,74 +548,77 @@ def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) + deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/CheckNameAvailability"} # type: ignore - + check_name_availability.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/CheckNameAvailability" + } @distributed_trace def list( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> Iterable[_models.ArmDisasterRecoveryListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> Iterable["_models.ArmDisasterRecovery"]: """Gets all Alias(Disaster Recovery configurations). - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ArmDisasterRecoveryListResult or the result of - cls(response) + :return: An iterator like instance of either ArmDisasterRecovery or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.ArmDisasterRecoveryListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.ArmDisasterRecovery] + :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', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ArmDisasterRecoveryListResult] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[_models.ArmDisasterRecoveryListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -588,16 +626,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("ArmDisasterRecoveryListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -608,49 +644,124 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs" + } - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, namespace_name: str, alias: str, parameters: _models.ArmDisasterRecovery, + *, + content_type: str = "application/json", **kwargs: Any ) -> Optional[_models.ArmDisasterRecovery]: """Creates or updates a new Alias(Disaster Recovery configuration). - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: str :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). + Required. :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.ArmDisasterRecovery + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ArmDisasterRecovery, or the result of cls(response) + :return: ArmDisasterRecovery or None or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.ArmDisasterRecovery or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + alias: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> Optional[_models.ArmDisasterRecovery]: + """Creates or updates a new Alias(Disaster Recovery configuration). + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: str + :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). + Required. + :type 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: ArmDisasterRecovery or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.ArmDisasterRecovery or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + alias: str, + parameters: Union[_models.ArmDisasterRecovery, IO], + **kwargs: Any + ) -> Optional[_models.ArmDisasterRecovery]: + """Creates or updates a new Alias(Disaster Recovery configuration). + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: str + :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). Is + either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.ArmDisasterRecovery 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: ArmDisasterRecovery or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.ArmDisasterRecovery or None + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ArmDisasterRecovery]] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.ArmDisasterRecovery]] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'ArmDisasterRecovery') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ArmDisasterRecovery") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -660,18 +771,18 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - 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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -681,67 +792,65 @@ def create_or_update( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ArmDisasterRecovery', pipeline_response) + deserialized = self._deserialize("ArmDisasterRecovery", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}"} # type: ignore - + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}" + } @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - alias: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, alias: str, **kwargs: Any ) -> None: """Deletes an Alias(Disaster Recovery configuration). - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: 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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, alias=alias, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -752,60 +861,58 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}"} # type: ignore - + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}" + } @distributed_trace def get( - self, - resource_group_name: str, - namespace_name: str, - alias: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, alias: str, **kwargs: Any ) -> _models.ArmDisasterRecovery: """Retrieves Alias(Disaster Recovery configuration) for primary or secondary namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ArmDisasterRecovery, or the result of cls(response) + :return: ArmDisasterRecovery or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.ArmDisasterRecovery - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ArmDisasterRecovery] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[_models.ArmDisasterRecovery] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, alias=alias, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -813,68 +920,66 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ArmDisasterRecovery', pipeline_response) + deserialized = self._deserialize("ArmDisasterRecovery", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}" + } @distributed_trace def break_pairing( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - alias: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, alias: str, **kwargs: Any ) -> None: """This operation disables the Disaster Recovery and stops replicating changes from primary to secondary namespaces. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: 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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_break_pairing_request( resource_group_name=resource_group_name, namespace_name=namespace_name, alias=alias, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.break_pairing.metadata['url'], + template_url=self.break_pairing.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -885,60 +990,58 @@ def break_pairing( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - break_pairing.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/breakPairing"} # type: ignore - + break_pairing.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/breakPairing" + } @distributed_trace def fail_over( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - alias: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, alias: str, **kwargs: Any ) -> None: """Invokes GEO DR failover and reconfigure the alias to point to the secondary namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: 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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_fail_over_request( resource_group_name=resource_group_name, namespace_name=namespace_name, alias=alias, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.fail_over.metadata['url'], + template_url=self.fail_over.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -949,72 +1052,73 @@ def fail_over( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - fail_over.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/failover"} # type: ignore - + fail_over.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/failover" + } @distributed_trace def list_authorization_rules( - self, - resource_group_name: str, - namespace_name: str, - alias: str, - **kwargs: Any - ) -> Iterable[_models.SBAuthorizationRuleListResult]: + self, resource_group_name: str, namespace_name: str, alias: str, **kwargs: Any + ) -> Iterable["_models.SBAuthorizationRule"]: """Gets the authorization rules for a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of - cls(response) + :return: An iterator like instance of either SBAuthorizationRule or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRule] + :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', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRuleListResult] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[_models.SBAuthorizationRuleListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_authorization_rules_request( resource_group_name=resource_group_name, namespace_name=namespace_name, alias=alias, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_authorization_rules.metadata['url'], + template_url=self.list_authorization_rules.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_authorization_rules_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - alias=alias, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -1022,16 +1126,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("SBAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1042,48 +1144,45 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_authorization_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/AuthorizationRules"} # type: ignore + list_authorization_rules.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/AuthorizationRules" + } @distributed_trace def get_authorization_rule( - self, - resource_group_name: str, - namespace_name: str, - alias: str, - authorization_rule_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, alias: str, authorization_rule_name: str, **kwargs: Any ) -> _models.SBAuthorizationRule: """Gets an authorization rule for a namespace by rule name. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[_models.SBAuthorizationRule] = kwargs.pop("cls", None) - request = build_get_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -1091,18 +1190,17 @@ def get_authorization_rule( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_authorization_rule.metadata['url'], + template_url=self.get_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1110,52 +1208,50 @@ def get_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/AuthorizationRules/{authorizationRuleName}"} # type: ignore - + get_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/AuthorizationRules/{authorizationRuleName}" + } @distributed_trace def list_keys( - self, - resource_group_name: str, - namespace_name: str, - alias: str, - authorization_rule_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, alias: str, authorization_rule_name: str, **kwargs: Any ) -> _models.AccessKeys: """Gets the primary and secondary connection strings for the namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[_models.AccessKeys] = kwargs.pop("cls", None) - request = build_list_keys_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -1163,18 +1259,17 @@ def list_keys( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata['url'], + 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 + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1182,12 +1277,13 @@ def list_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + deserialized = self._deserialize("AccessKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/AuthorizationRules/{authorizationRuleName}/listKeys"} # type: ignore - + list_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/AuthorizationRules/{authorizationRuleName}/listKeys" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/_event_hubs_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/_event_hubs_operations.py index cb56d50dbebc8..dd1cd965cd6d9 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/_event_hubs_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/_event_hubs_operations.py @@ -6,11 +6,18 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,48 +27,52 @@ 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') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +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_namespace_request( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_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-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/eventhubs") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/eventhubs", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class EventHubsOperations: """ @@ -82,64 +93,65 @@ def __init__(self, *args, **kwargs): 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_namespace( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> Iterable[_models.EventHubListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> Iterable["_models.Eventhub"]: """Gets all the Event Hubs in a service bus Namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventHubListResult or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.EventHubListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Eventhub or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.Eventhub] + :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', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.EventHubListResult] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[_models.EventHubListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_namespace_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_namespace.metadata['url'], + template_url=self.list_by_namespace.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_by_namespace_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -147,16 +159,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("EventHubListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -167,8 +177,8 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_namespace.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/eventhubs"} # type: ignore + list_by_namespace.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/eventhubs" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/_migration_configs_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/_migration_configs_operations.py index 883b733d32328..b41a51f6f6aa9 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/_migration_configs_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/_migration_configs_operations.py @@ -6,11 +6,18 @@ # 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, Union, cast - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -22,251 +29,245 @@ 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') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +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, - namespace_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_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-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_and_start_migration_request_initial( +def build_create_and_start_migration_request( resource_group_name: str, namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], + config_name: Union[str, _models.MigrationConfigurationName], subscription_id: str, - *, - json: Optional[_models.MigrationConfigProperties] = None, - content: Any = 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', "2017-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: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "configName": _SERIALIZER.url("config_name", config_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "configName": _SERIALIZER.url("config_name", config_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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') + _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, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( resource_group_name: str, namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], + config_name: Union[str, _models.MigrationConfigurationName], 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-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "configName": _SERIALIZER.url("config_name", config_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "configName": _SERIALIZER.url("config_name", config_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( resource_group_name: str, namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], + config_name: Union[str, _models.MigrationConfigurationName], 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-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "configName": _SERIALIZER.url("config_name", config_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "configName": _SERIALIZER.url("config_name", config_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_complete_migration_request( resource_group_name: str, namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], + config_name: Union[str, _models.MigrationConfigurationName], 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-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/upgrade") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/upgrade", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "configName": _SERIALIZER.url("config_name", config_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "configName": _SERIALIZER.url("config_name", config_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_revert_request( resource_group_name: str, namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], + config_name: Union[str, _models.MigrationConfigurationName], 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-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/revert") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/revert", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "configName": _SERIALIZER.url("config_name", config_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "configName": _SERIALIZER.url("config_name", config_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class MigrationConfigsOperations: """ @@ -287,65 +288,67 @@ def __init__(self, *args, **kwargs): 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, - namespace_name: str, - **kwargs: Any - ) -> Iterable[_models.MigrationConfigListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> Iterable["_models.MigrationConfigProperties"]: """Gets all migrationConfigurations. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MigrationConfigListResult or the result of + :return: An iterator like instance of either MigrationConfigProperties or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.MigrationConfigListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.MigrationConfigProperties] + :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', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MigrationConfigListResult] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[_models.MigrationConfigListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -353,16 +356,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("MigrationConfigListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -373,35 +374,44 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations" + } def _create_and_start_migration_initial( self, resource_group_name: str, namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], - parameters: _models.MigrationConfigProperties, + config_name: Union[str, _models.MigrationConfigurationName], + parameters: Union[_models.MigrationConfigProperties, IO], **kwargs: Any ) -> Optional[_models.MigrationConfigProperties]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.MigrationConfigProperties]] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.MigrationConfigProperties]] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'MigrationConfigProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "MigrationConfigProperties") - request = build_create_and_start_migration_request_initial( + request = build_create_and_start_migration_request( resource_group_name=resource_group_name, namespace_name=namespace_name, config_name=config_name, @@ -409,56 +419,63 @@ def _create_and_start_migration_initial( api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_and_start_migration_initial.metadata['url'], + content=_content, + template_url=self._create_and_start_migration_initial.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('MigrationConfigProperties', pipeline_response) + deserialized = self._deserialize("MigrationConfigProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_and_start_migration_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}"} # type: ignore - + _create_and_start_migration_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}" + } - @distributed_trace + @overload def begin_create_and_start_migration( self, resource_group_name: str, namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], + config_name: Union[str, _models.MigrationConfigurationName], parameters: _models.MigrationConfigProperties, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.MigrationConfigProperties]: """Creates Migration configuration and starts migration of entities from Standard to Premium namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :type config_name: str or ~azure.mgmt.servicebus.v2017_04_01.models.MigrationConfigurationName - :param parameters: Parameters required to create Migration Configuration. + :param parameters: Parameters required to create Migration Configuration. Required. :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.MigrationConfigProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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 @@ -471,113 +488,188 @@ def begin_create_and_start_migration( of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.servicebus.v2017_04_01.models.MigrationConfigProperties] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_and_start_migration( + self, + resource_group_name: str, + namespace_name: str, + config_name: Union[str, _models.MigrationConfigurationName], + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.MigrationConfigProperties]: + """Creates Migration configuration and starts migration of entities from Standard to Premium + namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param config_name: The configuration name. Should always be "$default". "$default" Required. + :type config_name: str or ~azure.mgmt.servicebus.v2017_04_01.models.MigrationConfigurationName + :param parameters: Parameters required to create Migration Configuration. Required. + :type 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 + :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 MigrationConfigProperties or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.servicebus.v2017_04_01.models.MigrationConfigProperties] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_and_start_migration( + self, + resource_group_name: str, + namespace_name: str, + config_name: Union[str, _models.MigrationConfigurationName], + parameters: Union[_models.MigrationConfigProperties, IO], + **kwargs: Any + ) -> LROPoller[_models.MigrationConfigProperties]: + """Creates Migration configuration and starts migration of entities from Standard to Premium + namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param config_name: The configuration name. Should always be "$default". "$default" Required. + :type config_name: str or ~azure.mgmt.servicebus.v2017_04_01.models.MigrationConfigurationName + :param parameters: Parameters required to create Migration Configuration. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.MigrationConfigProperties 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 MigrationConfigProperties or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.servicebus.v2017_04_01.models.MigrationConfigProperties] + :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', "2017-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.MigrationConfigProperties] - 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] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.MigrationConfigProperties] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._create_and_start_migration_initial( # type: ignore + raw_result = self._create_and_start_migration_initial( resource_group_name=resource_group_name, namespace_name=namespace_name, config_name=config_name, parameters=parameters, 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): - deserialized = self._deserialize('MigrationConfigProperties', pipeline_response) + deserialized = self._deserialize("MigrationConfigProperties", 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 + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create_and_start_migration.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}"} # type: ignore + begin_create_and_start_migration.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}" + } @distributed_trace def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], + config_name: Union[str, _models.MigrationConfigurationName], **kwargs: Any ) -> None: """Deletes a MigrationConfiguration. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :type config_name: str or ~azure.mgmt.servicebus.v2017_04_01.models.MigrationConfigurationName :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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, config_name=config_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -588,60 +680,62 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}"} # type: ignore - + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}" + } @distributed_trace def get( self, resource_group_name: str, namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], + config_name: Union[str, _models.MigrationConfigurationName], **kwargs: Any ) -> _models.MigrationConfigProperties: """Retrieves Migration Config. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :type config_name: str or ~azure.mgmt.servicebus.v2017_04_01.models.MigrationConfigurationName :keyword callable cls: A custom type or function that will be passed the direct response - :return: MigrationConfigProperties, or the result of cls(response) + :return: MigrationConfigProperties or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.MigrationConfigProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MigrationConfigProperties] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[_models.MigrationConfigProperties] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, config_name=config_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -649,69 +743,71 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('MigrationConfigProperties', pipeline_response) + deserialized = self._deserialize("MigrationConfigProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}" + } @distributed_trace def complete_migration( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], + config_name: Union[str, _models.MigrationConfigurationName], **kwargs: Any ) -> None: """This operation Completes Migration of entities by pointing the connection strings to Premium namespace and any entities created after the operation will be under Premium Namespace. CompleteMigration operation will fail when entity migration is in-progress. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :type config_name: str or ~azure.mgmt.servicebus.v2017_04_01.models.MigrationConfigurationName :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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_complete_migration_request( resource_group_name=resource_group_name, namespace_name=namespace_name, config_name=config_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.complete_migration.metadata['url'], + template_url=self.complete_migration.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -722,60 +818,62 @@ def complete_migration( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - complete_migration.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/upgrade"} # type: ignore - + complete_migration.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/upgrade" + } @distributed_trace def revert( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], + config_name: Union[str, _models.MigrationConfigurationName], **kwargs: Any ) -> None: """This operation reverts Migration. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :type config_name: str or ~azure.mgmt.servicebus.v2017_04_01.models.MigrationConfigurationName :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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_revert_request( resource_group_name=resource_group_name, namespace_name=namespace_name, config_name=config_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.revert.metadata['url'], + template_url=self.revert.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -786,5 +884,6 @@ def revert( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - revert.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/revert"} # type: ignore - + revert.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/revert" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/_namespaces_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/_namespaces_operations.py index e5bbab201477c..04eb334ac9f12 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/_namespaces_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/_namespaces_operations.py @@ -6,11 +6,18 @@ # 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, Union, cast - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -22,696 +29,597 @@ 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') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_authorization_rules_request( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_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-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_authorization_rule_request( - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - subscription_id: str, - *, - json: Optional[_models.SBAuthorizationRule] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_name: str, authorization_rule_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-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: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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, - 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_authorization_rule_request( - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, authorization_rule_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-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_authorization_rule_request( - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, authorization_rule_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-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_keys_request( - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, authorization_rule_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-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/listKeys") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/listKeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_regenerate_keys_request( - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - subscription_id: str, - *, - json: Optional[_models.RegenerateAccessKeyParameters] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_name: str, authorization_rule_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-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: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/regenerateKeys") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/regenerateKeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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, - 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_check_name_availability_request( - subscription_id: str, - *, - json: Optional[_models.CheckNameAvailability] = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: + +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-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: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/CheckNameAvailability") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/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: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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, - 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_migrate_request( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - *, - json: Optional[_models.SBNamespaceMigrate] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_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-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: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrate", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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, - 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_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_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-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/namespaces") 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: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _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: + +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-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _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( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - *, - json: Optional[_models.SBNamespace] = None, - content: Any = None, - **kwargs: Any + +def build_create_or_update_request( + resource_group_name: str, namespace_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-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: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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, - 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( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - **kwargs: Any + +def build_delete_request( + resource_group_name: str, namespace_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-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_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-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _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, - namespace_name: str, - subscription_id: str, - *, - json: Optional[_models.SBNamespaceUpdateParameters] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_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-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: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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, - 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_create_or_update_network_rule_set_request( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - *, - json: Optional[_models.NetworkRuleSet] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_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-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: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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, - 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_get_network_rule_set_request( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_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-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_network_rule_sets_request( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_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-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + class NamespacesOperations: """ @@ -732,65 +640,66 @@ def __init__(self, *args, **kwargs): 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_authorization_rules( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> Iterable[_models.SBAuthorizationRuleListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> Iterable["_models.SBAuthorizationRule"]: """Gets the authorization rules for a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of - cls(response) + :return: An iterator like instance of either SBAuthorizationRule or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRule] + :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', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRuleListResult] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[_models.SBAuthorizationRuleListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_authorization_rules_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_authorization_rules.metadata['url'], + template_url=self.list_authorization_rules.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_authorization_rules_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -798,16 +707,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("SBAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -818,49 +725,122 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_authorization_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules"} # type: ignore + list_authorization_rules.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules" + } - @distributed_trace + @overload def create_or_update_authorization_rule( self, resource_group_name: str, namespace_name: str, authorization_rule_name: str, parameters: _models.SBAuthorizationRule, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SBAuthorizationRule: """Creates or updates an authorization rule for a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: The shared access authorization rule. + :param parameters: The shared access authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates or updates an authorization rule for a namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Required. + :type 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: SBAuthorizationRule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: Union[_models.SBAuthorizationRule, IO], + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates or updates an authorization rule for a namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRule 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: SBAuthorizationRule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SBAuthorizationRule] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'SBAuthorizationRule') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBAuthorizationRule") request = build_create_or_update_authorization_rule_request( resource_group_name=resource_group_name, @@ -870,18 +850,18 @@ def create_or_update_authorization_rule( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_authorization_rule.metadata['url'], + content=_content, + template_url=self.create_or_update_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -889,67 +869,65 @@ def create_or_update_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}"} # type: ignore - + create_or_update_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}" + } @distributed_trace def delete_authorization_rule( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, authorization_rule_name: str, **kwargs: Any ) -> None: """Deletes a namespace authorization rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_authorization_rule.metadata['url'], + template_url=self.delete_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -960,60 +938,58 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}"} # type: ignore - + delete_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}" + } @distributed_trace def get_authorization_rule( - self, - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, authorization_rule_name: str, **kwargs: Any ) -> _models.SBAuthorizationRule: """Gets an authorization rule for a namespace by rule name. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[_models.SBAuthorizationRule] = kwargs.pop("cls", None) - request = build_get_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_authorization_rule.metadata['url'], + template_url=self.get_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1021,67 +997,65 @@ def get_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}"} # type: ignore - + get_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}" + } @distributed_trace def list_keys( - self, - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, authorization_rule_name: str, **kwargs: Any ) -> _models.AccessKeys: """Gets the primary and secondary connection strings for the namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[_models.AccessKeys] = kwargs.pop("cls", None) - request = build_list_keys_request( resource_group_name=resource_group_name, namespace_name=namespace_name, authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata['url'], + 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 + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1089,53 +1063,127 @@ def list_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + deserialized = self._deserialize("AccessKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/listKeys"} # type: ignore - + list_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/listKeys" + } - @distributed_trace + @overload def regenerate_keys( self, resource_group_name: str, namespace_name: str, authorization_rule_name: str, parameters: _models.RegenerateAccessKeyParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.AccessKeys: """Regenerates the primary or secondary connection strings for the namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate the authorization rule. + :param parameters: Parameters supplied to regenerate the authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.RegenerateAccessKeyParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AccessKeys: + """Regenerates the primary or secondary connection strings for the namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Required. + :type 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: AccessKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: Union[_models.RegenerateAccessKeyParameters, IO], + **kwargs: Any + ) -> _models.AccessKeys: + """Regenerates the primary or secondary connection strings for the namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.RegenerateAccessKeyParameters 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: AccessKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AccessKeys] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RegenerateAccessKeyParameters") request = build_regenerate_keys_request( resource_group_name=resource_group_name, @@ -1145,18 +1193,18 @@ def regenerate_keys( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_keys.metadata['url'], + content=_content, + template_url=self.regenerate_keys.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1164,62 +1212,108 @@ def regenerate_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + deserialized = self._deserialize("AccessKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/regenerateKeys"} # type: ignore + regenerate_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/regenerateKeys" + } + + @overload + def check_name_availability( + self, parameters: _models.CheckNameAvailability, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param parameters: Parameters to check availability of the given namespace name. Required. + :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.CheckNameAvailability + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckNameAvailabilityResult or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + def check_name_availability( + self, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param parameters: Parameters to check availability of the given namespace name. Required. + :type 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: CheckNameAvailabilityResult or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def check_name_availability( - self, - parameters: _models.CheckNameAvailability, - **kwargs: Any + self, parameters: Union[_models.CheckNameAvailability, IO], **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Check the give namespace name availability. - :param parameters: Parameters to check availability of the given namespace name. - :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.CheckNameAvailability + :param parameters: Parameters to check availability of the given namespace name. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.CheckNameAvailability 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: CheckNameAvailabilityResult, or the result of cls(response) + :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.CheckNameAvailabilityResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.CheckNameAvailabilityResult] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CheckNameAvailabilityResult] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'CheckNameAvailability') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "CheckNameAvailability") 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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1227,50 +1321,118 @@ def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) + deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/CheckNameAvailability"} # type: ignore - + check_name_availability.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/CheckNameAvailability" + } - @distributed_trace + @overload def migrate( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, parameters: _models.SBNamespaceMigrate, + *, + content_type: str = "application/json", **kwargs: Any ) -> None: """This operation Migrate the given namespace to provided name type. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: Parameters supplied to migrate namespace type. + :param parameters: Parameters supplied to migrate namespace type. Required. :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.SBNamespaceMigrate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default 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: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def migrate( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """This operation Migrate the given namespace to provided name type. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to migrate namespace type. Required. + :type 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: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def migrate( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + namespace_name: str, + parameters: Union[_models.SBNamespaceMigrate, IO], + **kwargs: Any + ) -> None: + """This operation Migrate the given namespace to provided name type. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to migrate namespace type. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.SBNamespaceMigrate 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: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'SBNamespaceMigrate') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBNamespaceMigrate") request = build_migrate_request( resource_group_name=resource_group_name, @@ -1279,18 +1441,18 @@ def migrate( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, json=_json, - template_url=self.migrate.metadata['url'], + content=_content, + template_url=self.migrate.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1301,57 +1463,61 @@ def migrate( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - migrate.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrate"} # type: ignore - + migrate.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrate" + } @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable[_models.SBNamespaceListResult]: + def list(self, **kwargs: Any) -> Iterable["_models.SBNamespace"]: """Gets all the available namespaces within the subscription, irrespective of the resource groups. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBNamespaceListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.SBNamespaceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either SBNamespace or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.SBNamespace] + :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', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBNamespaceListResult] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[_models.SBNamespaceListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -1359,16 +1525,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("SBNamespaceListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1379,65 +1543,64 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/namespaces"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/namespaces"} @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable[_models.SBNamespaceListResult]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.SBNamespace"]: """Gets the available namespaces within a resource group. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. 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 SBNamespaceListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.SBNamespaceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either SBNamespace or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.SBNamespace] + :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', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBNamespaceListResult] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[_models.SBNamespaceListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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'], + 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 + request.url = self._client.format_url(request.url) else: - - 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=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -1445,16 +1608,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("SBNamespaceListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1465,90 +1626,138 @@ 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.ServiceBus/namespaces"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces" + } def _create_or_update_initial( - self, - resource_group_name: str, - namespace_name: str, - parameters: _models.SBNamespace, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, parameters: Union[_models.SBNamespace, IO], **kwargs: Any ) -> Optional[_models.SBNamespace]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.SBNamespace]] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.SBNamespace]] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'SBNamespace') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBNamespace") - request = build_create_or_update_request_initial( + request = build_create_or_update_request( resource_group_name=resource_group_name, namespace_name=namespace_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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('SBNamespace', pipeline_response) + deserialized = self._deserialize("SBNamespace", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('SBNamespace', pipeline_response) + deserialized = self._deserialize("SBNamespace", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore - + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}" + } - @distributed_trace + @overload def begin_create_or_update( self, resource_group_name: str, namespace_name: str, parameters: _models.SBNamespace, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.SBNamespace]: """Creates or updates a service namespace. Once created, this namespace's resource manifest is immutable. This operation is idempotent. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: Parameters supplied to create a namespace resource. + :param parameters: Parameters supplied to create a namespace resource. Required. :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.SBNamespace + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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 SBNamespace or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.servicebus.v2017_04_01.models.SBNamespace] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.SBNamespace]: + """Creates or updates a service namespace. Once created, this namespace's resource manifest is + immutable. This operation is idempotent. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to create a namespace resource. Required. + :type 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 :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 @@ -1560,121 +1769,142 @@ def begin_create_or_update( :return: An instance of LROPoller that returns either SBNamespace or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.servicebus.v2017_04_01.models.SBNamespace] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, resource_group_name: str, namespace_name: str, parameters: Union[_models.SBNamespace, IO], **kwargs: Any + ) -> LROPoller[_models.SBNamespace]: + """Creates or updates a service namespace. Once created, this namespace's resource manifest is + immutable. This operation is idempotent. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to create a namespace resource. Is either a model type + or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.SBNamespace 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 SBNamespace or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.servicebus.v2017_04_01.models.SBNamespace] + :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', "2017-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBNamespace] - 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] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SBNamespace] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._create_or_update_initial( # type: ignore + raw_result = self._create_or_update_initial( resource_group_name=resource_group_name, namespace_name=namespace_name, parameters=parameters, 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): - deserialized = self._deserialize('SBNamespace', pipeline_response) + deserialized = self._deserialize("SBNamespace", 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 + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}" + } def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, **kwargs: Any ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request_initial( + request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + 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 + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}" + } @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete(self, resource_group_name: str, namespace_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes an existing namespace. This operation also removes all associated resources under the namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_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. @@ -1686,103 +1916,94 @@ def begin_delete( # pylint: disable=inconsistent-return-statements 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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: 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] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, namespace_name=namespace_name, api_version=api_version, - 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 = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}" + } @distributed_trace - def get( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> _models.SBNamespace: + def get(self, resource_group_name: str, namespace_name: str, **kwargs: Any) -> _models.SBNamespace: """Gets a description for the specified namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBNamespace, or the result of cls(response) + :return: SBNamespace or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.SBNamespace - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBNamespace] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[_models.SBNamespace] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1790,51 +2011,121 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBNamespace', pipeline_response) + deserialized = self._deserialize("SBNamespace", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}" + } - @distributed_trace + @overload def update( self, resource_group_name: str, namespace_name: str, parameters: _models.SBNamespaceUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> Optional[_models.SBNamespace]: """Updates a service namespace. Once created, this namespace's resource manifest is immutable. This operation is idempotent. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: Parameters supplied to update a namespace resource. + :param parameters: Parameters supplied to update a namespace resource. Required. :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.SBNamespaceUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBNamespace, or the result of cls(response) + :return: SBNamespace or None or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.SBNamespace or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> Optional[_models.SBNamespace]: + """Updates a service namespace. Once created, this namespace's resource manifest is immutable. + This operation is idempotent. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to update a namespace resource. Required. + :type 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: SBNamespace or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.SBNamespace or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + namespace_name: str, + parameters: Union[_models.SBNamespaceUpdateParameters, IO], + **kwargs: Any + ) -> Optional[_models.SBNamespace]: + """Updates a service namespace. Once created, this namespace's resource manifest is immutable. + This operation is idempotent. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to update a namespace resource. Is either a model type + or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.SBNamespaceUpdateParameters 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: SBNamespace or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.SBNamespace or None + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.SBNamespace]] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.SBNamespace]] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'SBNamespaceUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBNamespaceUpdateParameters") request = build_update_request( resource_group_name=resource_group_name, @@ -1843,18 +2134,18 @@ def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -1864,53 +2155,120 @@ def update( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('SBNamespace', pipeline_response) + deserialized = self._deserialize("SBNamespace", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('SBNamespace', pipeline_response) + deserialized = self._deserialize("SBNamespace", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore - + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}" + } - @distributed_trace + @overload def create_or_update_network_rule_set( self, resource_group_name: str, namespace_name: str, parameters: _models.NetworkRuleSet, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.NetworkRuleSet: """Create or update NetworkRuleSet for a Namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: The Namespace IpFilterRule. + :param parameters: The Namespace IpFilterRule. Required. :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.NetworkRuleSet + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: NetworkRuleSet or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.NetworkRuleSet + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_network_rule_set( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.NetworkRuleSet: + """Create or update NetworkRuleSet for a Namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: The Namespace IpFilterRule. Required. + :type 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: NetworkRuleSet, or the result of cls(response) + :return: NetworkRuleSet or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.NetworkRuleSet - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update_network_rule_set( + self, + resource_group_name: str, + namespace_name: str, + parameters: Union[_models.NetworkRuleSet, IO], + **kwargs: Any + ) -> _models.NetworkRuleSet: + """Create or update NetworkRuleSet for a Namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: The Namespace IpFilterRule. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.NetworkRuleSet 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: NetworkRuleSet or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.NetworkRuleSet + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.NetworkRuleSet] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.NetworkRuleSet] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'NetworkRuleSet') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "NetworkRuleSet") request = build_create_or_update_network_rule_set_request( resource_group_name=resource_group_name, @@ -1919,18 +2277,18 @@ def create_or_update_network_rule_set( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_network_rule_set.metadata['url'], + content=_content, + template_url=self.create_or_update_network_rule_set.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1938,63 +2296,62 @@ def create_or_update_network_rule_set( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('NetworkRuleSet', pipeline_response) + deserialized = self._deserialize("NetworkRuleSet", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_network_rule_set.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default"} # type: ignore - + create_or_update_network_rule_set.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default" + } @distributed_trace def get_network_rule_set( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, **kwargs: Any ) -> _models.NetworkRuleSet: """Gets NetworkRuleSet for a Namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: NetworkRuleSet, or the result of cls(response) + :return: NetworkRuleSet or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.NetworkRuleSet - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.NetworkRuleSet] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[_models.NetworkRuleSet] = kwargs.pop("cls", None) - request = build_get_network_rule_set_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_network_rule_set.metadata['url'], + template_url=self.get_network_rule_set.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -2002,74 +2359,76 @@ def get_network_rule_set( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('NetworkRuleSet', pipeline_response) + deserialized = self._deserialize("NetworkRuleSet", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_network_rule_set.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default"} # type: ignore - + get_network_rule_set.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default" + } @distributed_trace def list_network_rule_sets( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> Iterable[_models.NetworkRuleSetListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> Iterable["_models.NetworkRuleSet"]: """Gets list of NetworkRuleSet for a Namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either NetworkRuleSetListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.NetworkRuleSetListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either NetworkRuleSet or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.NetworkRuleSet] + :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', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.NetworkRuleSetListResult] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[_models.NetworkRuleSetListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_network_rule_sets_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_network_rule_sets.metadata['url'], + template_url=self.list_network_rule_sets.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_network_rule_sets_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -2077,16 +2436,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("NetworkRuleSetListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2097,8 +2454,8 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_network_rule_sets.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets"} # type: ignore + list_network_rule_sets.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/_operations.py index d45dbc6315d61..a1814cc45836c 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/_operations.py @@ -6,11 +6,18 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,38 +27,38 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +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: + +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-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.ServiceBus/operations") # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class Operations: """ @@ -72,52 +79,56 @@ def __init__(self, *args, **kwargs): 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 ServiceBus 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.servicebus.v2017_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.servicebus.v2017_04_01.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', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_request( - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -125,16 +136,14 @@ 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) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -145,8 +154,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.ServiceBus/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.ServiceBus/operations"} diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/_patch.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/_patch.py index 0ad201a8c586e..f7dd32510333d 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/_patch.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/_premium_messaging_regions_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/_premium_messaging_regions_operations.py index ff17dfe25d290..63faa8aa98f55 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/_premium_messaging_regions_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/_premium_messaging_regions_operations.py @@ -6,11 +6,18 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,44 +27,45 @@ 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') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +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, - **kwargs: Any -) -> HttpRequest: + +def build_list_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-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/premiumMessagingRegions") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/premiumMessagingRegions" + ) # pylint: disable=line-too-long 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: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class PremiumMessagingRegionsOperations: """ @@ -78,55 +86,59 @@ def __init__(self, *args, **kwargs): 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.PremiumMessagingRegionsListResult]: + def list(self, **kwargs: Any) -> Iterable["_models.PremiumMessagingRegions"]: """Gets the available premium messaging regions for servicebus. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PremiumMessagingRegionsListResult or the result of + :return: An iterator like instance of either PremiumMessagingRegions or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.PremiumMessagingRegionsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.PremiumMessagingRegions] + :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', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PremiumMessagingRegionsListResult] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[_models.PremiumMessagingRegionsListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -134,16 +146,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("PremiumMessagingRegionsListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -154,8 +164,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': "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/premiumMessagingRegions"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/premiumMessagingRegions"} diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/_queues_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/_queues_operations.py index 979a0614b8632..f02345daa41d7 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/_queues_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/_queues_operations.py @@ -6,11 +6,18 @@ # 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 msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,50 +27,52 @@ 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') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_authorization_rules_request( - resource_group_name: str, - namespace_name: str, - queue_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, queue_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-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_authorization_rule_request( @@ -72,47 +81,43 @@ def build_create_or_update_authorization_rule_request( queue_name: str, authorization_rule_name: str, subscription_id: str, - *, - json: Optional[_models.SBAuthorizationRule] = None, - content: Any = 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', "2017-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: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', min_length=1), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, "str", min_length=1), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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') + _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, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_authorization_rule_request( @@ -126,34 +131,35 @@ def build_delete_authorization_rule_request( _headers = case_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-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', min_length=1), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, "str", min_length=1), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_authorization_rule_request( @@ -167,34 +173,35 @@ def build_get_authorization_rule_request( _headers = case_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-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', min_length=1), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, "str", min_length=1), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_keys_request( @@ -208,34 +215,35 @@ def build_list_keys_request( _headers = case_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-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/ListKeys") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/ListKeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', min_length=1), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, "str", min_length=1), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_regenerate_keys_request( @@ -244,47 +252,43 @@ def build_regenerate_keys_request( queue_name: str, authorization_rule_name: str, subscription_id: str, - *, - json: Optional[_models.RegenerateAccessKeyParameters] = None, - content: Any = 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', "2017-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: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/regenerateKeys") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/regenerateKeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', min_length=1), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, "str", min_length=1), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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') + _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, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_by_namespace_request( @@ -299,161 +303,141 @@ def build_list_by_namespace_request( _headers = case_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-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if skip is not None: - _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', maximum=1000, minimum=0) + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", maximum=1000, minimum=0) if top is not None: - _params['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", maximum=1000, minimum=1) # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( - resource_group_name: str, - namespace_name: str, - queue_name: str, - subscription_id: str, - *, - json: Optional[_models.SBQueue] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_name: str, queue_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-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: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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') + _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, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - namespace_name: str, - queue_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, queue_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-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - namespace_name: str, - queue_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, queue_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-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class QueuesOperations: """ @@ -474,70 +458,69 @@ def __init__(self, *args, **kwargs): 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_authorization_rules( - self, - resource_group_name: str, - namespace_name: str, - queue_name: str, - **kwargs: Any - ) -> Iterable[_models.SBAuthorizationRuleListResult]: + self, resource_group_name: str, namespace_name: str, queue_name: str, **kwargs: Any + ) -> Iterable["_models.SBAuthorizationRule"]: """Gets all authorization rules for a queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of - cls(response) + :return: An iterator like instance of either SBAuthorizationRule or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRule] + :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', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRuleListResult] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[_models.SBAuthorizationRuleListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_authorization_rules_request( resource_group_name=resource_group_name, namespace_name=namespace_name, queue_name=queue_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_authorization_rules.metadata['url'], + template_url=self.list_authorization_rules.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_authorization_rules_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - queue_name=queue_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -545,16 +528,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("SBAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -565,13 +546,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_authorization_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules"} # type: ignore + list_authorization_rules.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules" + } - @distributed_trace + @overload def create_or_update_authorization_rule( self, resource_group_name: str, @@ -579,38 +560,117 @@ def create_or_update_authorization_rule( queue_name: str, authorization_rule_name: str, parameters: _models.SBAuthorizationRule, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SBAuthorizationRule: """Creates an authorization rule for a queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: The shared access authorization rule. + :param parameters: The shared access authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBAuthorizationRule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates an authorization rule for a queue. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Required. + :type 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: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: Union[_models.SBAuthorizationRule, IO], + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates an authorization rule for a queue. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRule 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: SBAuthorizationRule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SBAuthorizationRule] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'SBAuthorizationRule') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBAuthorizationRule") request = build_create_or_update_authorization_rule_request( resource_group_name=resource_group_name, @@ -621,18 +681,18 @@ def create_or_update_authorization_rule( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_authorization_rule.metadata['url'], + content=_content, + template_url=self.create_or_update_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -640,15 +700,16 @@ def create_or_update_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}"} # type: ignore - + create_or_update_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}" + } @distributed_trace def delete_authorization_rule( # pylint: disable=inconsistent-return-statements @@ -661,31 +722,33 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements ) -> None: """Deletes a queue authorization rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -693,18 +756,17 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_authorization_rule.metadata['url'], + template_url=self.delete_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -715,8 +777,9 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}"} # type: ignore - + delete_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}" + } @distributed_trace def get_authorization_rule( @@ -729,31 +792,33 @@ def get_authorization_rule( ) -> _models.SBAuthorizationRule: """Gets an authorization rule for a queue by rule name. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[_models.SBAuthorizationRule] = kwargs.pop("cls", None) - request = build_get_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -761,18 +826,17 @@ def get_authorization_rule( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_authorization_rule.metadata['url'], + template_url=self.get_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -780,15 +844,16 @@ def get_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}"} # type: ignore - + get_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}" + } @distributed_trace def list_keys( @@ -801,31 +866,33 @@ def list_keys( ) -> _models.AccessKeys: """Primary and secondary connection strings to the queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[_models.AccessKeys] = kwargs.pop("cls", None) - request = build_list_keys_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -833,18 +900,17 @@ def list_keys( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata['url'], + 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 + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -852,17 +918,18 @@ def list_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + deserialized = self._deserialize("AccessKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/ListKeys"} # type: ignore - + list_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/ListKeys" + } - @distributed_trace + @overload def regenerate_keys( self, resource_group_name: str, @@ -870,38 +937,117 @@ def regenerate_keys( queue_name: str, authorization_rule_name: str, parameters: _models.RegenerateAccessKeyParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.AccessKeys: """Regenerates the primary or secondary connection strings to the queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate the authorization rule. + :param parameters: Parameters supplied to regenerate the authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.RegenerateAccessKeyParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AccessKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AccessKeys: + """Regenerates the primary or secondary connection strings to the queue. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Required. + :type 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: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: Union[_models.RegenerateAccessKeyParameters, IO], + **kwargs: Any + ) -> _models.AccessKeys: + """Regenerates the primary or secondary connection strings to the queue. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.RegenerateAccessKeyParameters 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: AccessKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AccessKeys] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RegenerateAccessKeyParameters") request = build_regenerate_keys_request( resource_group_name=resource_group_name, @@ -912,18 +1058,18 @@ def regenerate_keys( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_keys.metadata['url'], + content=_content, + template_url=self.regenerate_keys.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -931,15 +1077,16 @@ def regenerate_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + deserialized = self._deserialize("AccessKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/regenerateKeys"} # type: ignore - + regenerate_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/regenerateKeys" + } @distributed_trace def list_by_namespace( @@ -949,12 +1096,12 @@ def list_by_namespace( skip: Optional[int] = None, top: Optional[int] = None, **kwargs: Any - ) -> Iterable[_models.SBQueueListResult]: + ) -> Iterable["_models.SBQueue"]: """Gets the queues within a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :param skip: Skip is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skip @@ -964,53 +1111,56 @@ def list_by_namespace( Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBQueueListResult or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.SBQueueListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either SBQueue or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.SBQueue] + :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', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBQueueListResult] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[_models.SBQueueListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_namespace_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, - api_version=api_version, skip=skip, top=top, - template_url=self.list_by_namespace.metadata['url'], + api_version=api_version, + template_url=self.list_by_namespace.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_by_namespace_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - skip=skip, - top=top, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -1018,16 +1168,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("SBQueueListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1038,49 +1186,122 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_namespace.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues"} # type: ignore + list_by_namespace.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues" + } - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, namespace_name: str, queue_name: str, parameters: _models.SBQueue, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SBQueue: """Creates or updates a Service Bus queue. This operation is idempotent. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param parameters: Parameters supplied to create or update a queue resource. + :param parameters: Parameters supplied to create or update a queue resource. Required. :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.SBQueue + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBQueue or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.SBQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBQueue: + """Creates or updates a Service Bus queue. This operation is idempotent. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param parameters: Parameters supplied to create or update a queue resource. Required. + :type 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: SBQueue, or the result of cls(response) + :return: SBQueue or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.SBQueue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + parameters: Union[_models.SBQueue, IO], + **kwargs: Any + ) -> _models.SBQueue: + """Creates or updates a Service Bus queue. This operation is idempotent. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param parameters: Parameters supplied to create or update a queue resource. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.SBQueue 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: SBQueue or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.SBQueue + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBQueue] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SBQueue] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'SBQueue') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBQueue") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -1090,18 +1311,18 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - 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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1109,67 +1330,65 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBQueue', pipeline_response) + deserialized = self._deserialize("SBQueue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}"} # type: ignore - + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}" + } @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - queue_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, queue_name: str, **kwargs: Any ) -> None: """Deletes a queue from the specified namespace in a resource group. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, queue_name=queue_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1180,60 +1399,56 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}"} # type: ignore - + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}" + } @distributed_trace - def get( - self, - resource_group_name: str, - namespace_name: str, - queue_name: str, - **kwargs: Any - ) -> _models.SBQueue: + def get(self, resource_group_name: str, namespace_name: str, queue_name: str, **kwargs: Any) -> _models.SBQueue: """Returns a description for the specified queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBQueue, or the result of cls(response) + :return: SBQueue or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.SBQueue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBQueue] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[_models.SBQueue] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, queue_name=queue_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1241,12 +1456,13 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBQueue', pipeline_response) + deserialized = self._deserialize("SBQueue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/_regions_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/_regions_operations.py index d0b4fce6a80d4..864e5d33591c2 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/_regions_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/_regions_operations.py @@ -6,11 +6,18 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,46 +27,46 @@ 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') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +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_sku_request( - subscription_id: str, - sku: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_by_sku_request(sku: 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-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/sku/{sku}/regions") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/sku/{sku}/regions" + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "sku": _SERIALIZER.url("sku", sku, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "sku": _SERIALIZER.url("sku", sku, "str", max_length=50, min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + class RegionsOperations: """ @@ -80,60 +87,62 @@ def __init__(self, *args, **kwargs): 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_sku( - self, - sku: str, - **kwargs: Any - ) -> Iterable[_models.PremiumMessagingRegionsListResult]: + def list_by_sku(self, sku: str, **kwargs: Any) -> Iterable["_models.PremiumMessagingRegions"]: """Gets the available Regions for a given sku. - :param sku: The sku type. + :param sku: The sku type. Required. :type sku: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PremiumMessagingRegionsListResult or the result of + :return: An iterator like instance of either PremiumMessagingRegions or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.PremiumMessagingRegionsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.PremiumMessagingRegions] + :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', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PremiumMessagingRegionsListResult] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[_models.PremiumMessagingRegionsListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_sku_request( - subscription_id=self._config.subscription_id, sku=sku, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_sku.metadata['url'], + template_url=self.list_by_sku.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_by_sku_request( - subscription_id=self._config.subscription_id, - sku=sku, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -141,16 +150,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("PremiumMessagingRegionsListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -161,8 +168,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_sku.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/sku/{sku}/regions"} # type: ignore + list_by_sku.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/sku/{sku}/regions"} diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/_rules_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/_rules_operations.py index 29ff6684739f9..8e62268907d74 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/_rules_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/_rules_operations.py @@ -6,11 +6,18 @@ # 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 msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,13 +27,20 @@ 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') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +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_subscriptions_request( resource_group_name: str, namespace_name: str, @@ -41,38 +55,37 @@ def build_list_by_subscriptions_request( _headers = case_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-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, "str", max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if skip is not None: - _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', maximum=1000, minimum=0) + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", maximum=1000, minimum=0) if top is not None: - _params['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", maximum=1000, minimum=1) # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( @@ -82,48 +95,42 @@ def build_create_or_update_request( subscription_name: str, rule_name: str, subscription_id: str, - *, - json: Optional[_models.Rule] = None, - content: Any = 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', "2017-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: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - "ruleName": _SERIALIZER.url("rule_name", rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, "str", max_length=50, min_length=1), + "ruleName": _SERIALIZER.url("rule_name", rule_name, "str", max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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') + _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, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( @@ -138,35 +145,34 @@ def build_delete_request( _headers = case_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-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - "ruleName": _SERIALIZER.url("rule_name", rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, "str", max_length=50, min_length=1), + "ruleName": _SERIALIZER.url("rule_name", rule_name, "str", max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( @@ -181,35 +187,35 @@ def build_get_request( _headers = case_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-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - "ruleName": _SERIALIZER.url("rule_name", rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, "str", max_length=50, min_length=1), + "ruleName": _SERIALIZER.url("rule_name", rule_name, "str", max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class RulesOperations: """ @@ -230,7 +236,6 @@ def __init__(self, *args, **kwargs): 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_subscriptions( self, @@ -241,16 +246,16 @@ def list_by_subscriptions( skip: Optional[int] = None, top: Optional[int] = None, **kwargs: Any - ) -> Iterable[_models.RuleListResult]: + ) -> Iterable["_models.Rule"]: """List all the rules within given topic-subscription. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str :param skip: Skip is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skip @@ -260,56 +265,58 @@ def list_by_subscriptions( Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RuleListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.RuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Rule or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.Rule] + :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', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.RuleListResult] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[_models.RuleListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscriptions_request( resource_group_name=resource_group_name, namespace_name=namespace_name, topic_name=topic_name, subscription_name=subscription_name, subscription_id=self._config.subscription_id, - api_version=api_version, skip=skip, top=top, - template_url=self.list_by_subscriptions.metadata['url'], + api_version=api_version, + template_url=self.list_by_subscriptions.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_by_subscriptions_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - topic_name=topic_name, - subscription_name=subscription_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - skip=skip, - top=top, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -317,16 +324,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("RuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -337,13 +342,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_subscriptions.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules"} # type: ignore + list_by_subscriptions.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules" + } - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, @@ -352,40 +357,125 @@ def create_or_update( subscription_name: str, rule_name: str, parameters: _models.Rule, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.Rule: """Creates a new rule and updates an existing rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str - :param rule_name: The rule name. + :param rule_name: The rule name. Required. :type rule_name: str - :param parameters: Parameters supplied to create a rule. + :param parameters: Parameters supplied to create a rule. Required. :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.Rule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Rule, or the result of cls(response) + :return: Rule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.Rule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Rule: + """Creates a new rule and updates an existing rule. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param rule_name: The rule name. Required. + :type rule_name: str + :param parameters: Parameters supplied to create a rule. Required. + :type 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: Rule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.Rule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + rule_name: str, + parameters: Union[_models.Rule, IO], + **kwargs: Any + ) -> _models.Rule: + """Creates a new rule and updates an existing rule. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param rule_name: The rule name. Required. + :type rule_name: str + :param parameters: Parameters supplied to create a rule. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.Rule 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: Rule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.Rule + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.Rule] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Rule] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'Rule') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Rule") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -397,18 +487,18 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - 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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -416,15 +506,16 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Rule', pipeline_response) + deserialized = self._deserialize("Rule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}"} # type: ignore - + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}" + } @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -438,33 +529,35 @@ def delete( # pylint: disable=inconsistent-return-statements ) -> None: """Deletes an existing rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str - :param rule_name: The rule name. + :param rule_name: The rule name. Required. :type rule_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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -473,18 +566,17 @@ def delete( # pylint: disable=inconsistent-return-statements rule_name=rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -495,8 +587,9 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}"} # type: ignore - + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}" + } @distributed_trace def get( @@ -510,33 +603,35 @@ def get( ) -> _models.Rule: """Retrieves the description for the specified rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str - :param rule_name: The rule name. + :param rule_name: The rule name. Required. :type rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Rule, or the result of cls(response) + :return: Rule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.Rule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Rule] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[_models.Rule] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -545,18 +640,17 @@ def get( rule_name=rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -564,12 +658,13 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Rule', pipeline_response) + deserialized = self._deserialize("Rule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/_subscriptions_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/_subscriptions_operations.py index 3a7086fd12dbd..c2a95f42f096b 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/_subscriptions_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/_subscriptions_operations.py @@ -6,11 +6,18 @@ # 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 msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,13 +27,20 @@ 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') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +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_topic_request( resource_group_name: str, namespace_name: str, @@ -40,37 +54,36 @@ def build_list_by_topic_request( _headers = case_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-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if skip is not None: - _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', maximum=1000, minimum=0) + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", maximum=1000, minimum=0) if top is not None: - _params['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", maximum=1000, minimum=1) # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( @@ -79,47 +92,41 @@ def build_create_or_update_request( topic_name: str, subscription_name: str, subscription_id: str, - *, - json: Optional[_models.SBSubscription] = None, - content: Any = 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', "2017-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: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, "str", max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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') + _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, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( @@ -133,34 +140,33 @@ def build_delete_request( _headers = case_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-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, "str", max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( @@ -174,34 +180,34 @@ def build_get_request( _headers = case_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-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, "str", max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class SubscriptionsOperations: """ @@ -222,7 +228,6 @@ def __init__(self, *args, **kwargs): 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_topic( self, @@ -232,14 +237,14 @@ def list_by_topic( skip: Optional[int] = None, top: Optional[int] = None, **kwargs: Any - ) -> Iterable[_models.SBSubscriptionListResult]: + ) -> Iterable["_models.SBSubscription"]: """List all the subscriptions under a specified topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str :param skip: Skip is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skip @@ -249,56 +254,57 @@ def list_by_topic( Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBSubscriptionListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.SBSubscriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either SBSubscription or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.SBSubscription] + :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', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBSubscriptionListResult] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[_models.SBSubscriptionListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_topic_request( resource_group_name=resource_group_name, namespace_name=namespace_name, topic_name=topic_name, subscription_id=self._config.subscription_id, - api_version=api_version, skip=skip, top=top, - template_url=self.list_by_topic.metadata['url'], + api_version=api_version, + template_url=self.list_by_topic.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_by_topic_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - topic_name=topic_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - skip=skip, - top=top, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -306,16 +312,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("SBSubscriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -326,13 +330,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_topic.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions"} # type: ignore + list_by_topic.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions" + } - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, @@ -340,38 +344,117 @@ def create_or_update( topic_name: str, subscription_name: str, parameters: _models.SBSubscription, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SBSubscription: """Creates a topic subscription. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str - :param parameters: Parameters supplied to create a subscription resource. + :param parameters: Parameters supplied to create a subscription resource. Required. :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.SBSubscription + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBSubscription or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.SBSubscription + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBSubscription: + """Creates a topic subscription. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param parameters: Parameters supplied to create a subscription resource. Required. + :type 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: SBSubscription or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.SBSubscription + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + parameters: Union[_models.SBSubscription, IO], + **kwargs: Any + ) -> _models.SBSubscription: + """Creates a topic subscription. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param parameters: Parameters supplied to create a subscription resource. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.SBSubscription 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: SBSubscription, or the result of cls(response) + :return: SBSubscription or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.SBSubscription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBSubscription] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SBSubscription] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'SBSubscription') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBSubscription") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -382,18 +465,18 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - 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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -401,52 +484,50 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBSubscription', pipeline_response) + deserialized = self._deserialize("SBSubscription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}"} # type: ignore - + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}" + } @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - subscription_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, topic_name: str, subscription_name: str, **kwargs: Any ) -> None: """Deletes a subscription from the specified topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -454,18 +535,17 @@ def delete( # pylint: disable=inconsistent-return-statements subscription_name=subscription_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -476,45 +556,43 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}"} # type: ignore - + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}" + } @distributed_trace def get( - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - subscription_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, topic_name: str, subscription_name: str, **kwargs: Any ) -> _models.SBSubscription: """Returns a subscription description for the specified topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBSubscription, or the result of cls(response) + :return: SBSubscription or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.SBSubscription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBSubscription] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[_models.SBSubscription] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -522,18 +600,17 @@ def get( subscription_name=subscription_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -541,12 +618,13 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBSubscription', pipeline_response) + deserialized = self._deserialize("SBSubscription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/_topics_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/_topics_operations.py index 11c7c9d66fe2d..78470e17cbc3b 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/_topics_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/_topics_operations.py @@ -6,11 +6,18 @@ # 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 msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,50 +27,52 @@ 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') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_authorization_rules_request( - resource_group_name: str, - namespace_name: str, - topic_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, topic_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-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_authorization_rule_request( @@ -72,47 +81,43 @@ def build_create_or_update_authorization_rule_request( topic_name: str, authorization_rule_name: str, subscription_id: str, - *, - json: Optional[_models.SBAuthorizationRule] = None, - content: Any = 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', "2017-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: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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') + _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, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_get_authorization_rule_request( @@ -126,34 +131,35 @@ def build_get_authorization_rule_request( _headers = case_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-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_authorization_rule_request( @@ -167,34 +173,35 @@ def build_delete_authorization_rule_request( _headers = case_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-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_list_keys_request( @@ -208,34 +215,35 @@ def build_list_keys_request( _headers = case_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-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/ListKeys") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/ListKeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_regenerate_keys_request( @@ -244,47 +252,43 @@ def build_regenerate_keys_request( topic_name: str, authorization_rule_name: str, subscription_id: str, - *, - json: Optional[_models.RegenerateAccessKeyParameters] = None, - content: Any = 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', "2017-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: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/regenerateKeys") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/regenerateKeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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') + _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, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_by_namespace_request( @@ -299,161 +303,141 @@ def build_list_by_namespace_request( _headers = case_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-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if skip is not None: - _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', maximum=1000, minimum=0) + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", maximum=1000, minimum=0) if top is not None: - _params['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", maximum=1000, minimum=1) # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( - resource_group_name: str, - namespace_name: str, - topic_name: str, - subscription_id: str, - *, - json: Optional[_models.SBTopic] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_name: str, topic_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-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: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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') + _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, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - namespace_name: str, - topic_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, topic_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-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - namespace_name: str, - topic_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, topic_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-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class TopicsOperations: """ @@ -474,70 +458,69 @@ def __init__(self, *args, **kwargs): 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_authorization_rules( - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - **kwargs: Any - ) -> Iterable[_models.SBAuthorizationRuleListResult]: + self, resource_group_name: str, namespace_name: str, topic_name: str, **kwargs: Any + ) -> Iterable["_models.SBAuthorizationRule"]: """Gets authorization rules for a topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of - cls(response) + :return: An iterator like instance of either SBAuthorizationRule or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRule] + :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', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRuleListResult] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[_models.SBAuthorizationRuleListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_authorization_rules_request( resource_group_name=resource_group_name, namespace_name=namespace_name, topic_name=topic_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_authorization_rules.metadata['url'], + template_url=self.list_authorization_rules.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_authorization_rules_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - topic_name=topic_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -545,16 +528,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("SBAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -565,13 +546,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_authorization_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules"} # type: ignore + list_authorization_rules.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules" + } - @distributed_trace + @overload def create_or_update_authorization_rule( self, resource_group_name: str, @@ -579,38 +560,117 @@ def create_or_update_authorization_rule( topic_name: str, authorization_rule_name: str, parameters: _models.SBAuthorizationRule, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SBAuthorizationRule: """Creates an authorization rule for the specified topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: The shared access authorization rule. + :param parameters: The shared access authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBAuthorizationRule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates an authorization rule for the specified topic. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Required. + :type 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: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: Union[_models.SBAuthorizationRule, IO], + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates an authorization rule for the specified topic. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRule 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: SBAuthorizationRule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SBAuthorizationRule] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'SBAuthorizationRule') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBAuthorizationRule") request = build_create_or_update_authorization_rule_request( resource_group_name=resource_group_name, @@ -621,18 +681,18 @@ def create_or_update_authorization_rule( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_authorization_rule.metadata['url'], + content=_content, + template_url=self.create_or_update_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -640,15 +700,16 @@ def create_or_update_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}"} # type: ignore - + create_or_update_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}" + } @distributed_trace def get_authorization_rule( @@ -661,31 +722,33 @@ def get_authorization_rule( ) -> _models.SBAuthorizationRule: """Returns the specified authorization rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[_models.SBAuthorizationRule] = kwargs.pop("cls", None) - request = build_get_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -693,18 +756,17 @@ def get_authorization_rule( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_authorization_rule.metadata['url'], + template_url=self.get_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -712,15 +774,16 @@ def get_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}"} # type: ignore - + get_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}" + } @distributed_trace def delete_authorization_rule( # pylint: disable=inconsistent-return-statements @@ -733,31 +796,33 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements ) -> None: """Deletes a topic authorization rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -765,18 +830,17 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_authorization_rule.metadata['url'], + template_url=self.delete_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -787,8 +851,9 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}"} # type: ignore - + delete_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}" + } @distributed_trace def list_keys( @@ -801,31 +866,33 @@ def list_keys( ) -> _models.AccessKeys: """Gets the primary and secondary connection strings for the topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[_models.AccessKeys] = kwargs.pop("cls", None) - request = build_list_keys_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -833,18 +900,17 @@ def list_keys( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata['url'], + 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 + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -852,17 +918,18 @@ def list_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + deserialized = self._deserialize("AccessKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/ListKeys"} # type: ignore - + list_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/ListKeys" + } - @distributed_trace + @overload def regenerate_keys( self, resource_group_name: str, @@ -870,38 +937,117 @@ def regenerate_keys( topic_name: str, authorization_rule_name: str, parameters: _models.RegenerateAccessKeyParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.AccessKeys: """Regenerates primary or secondary connection strings for the topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate the authorization rule. + :param parameters: Parameters supplied to regenerate the authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.RegenerateAccessKeyParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AccessKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AccessKeys: + """Regenerates primary or secondary connection strings for the topic. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Required. + :type 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: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: Union[_models.RegenerateAccessKeyParameters, IO], + **kwargs: Any + ) -> _models.AccessKeys: + """Regenerates primary or secondary connection strings for the topic. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.RegenerateAccessKeyParameters 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: AccessKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AccessKeys] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RegenerateAccessKeyParameters") request = build_regenerate_keys_request( resource_group_name=resource_group_name, @@ -912,18 +1058,18 @@ def regenerate_keys( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_keys.metadata['url'], + content=_content, + template_url=self.regenerate_keys.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -931,15 +1077,16 @@ def regenerate_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + deserialized = self._deserialize("AccessKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/regenerateKeys"} # type: ignore - + regenerate_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/regenerateKeys" + } @distributed_trace def list_by_namespace( @@ -949,12 +1096,12 @@ def list_by_namespace( skip: Optional[int] = None, top: Optional[int] = None, **kwargs: Any - ) -> Iterable[_models.SBTopicListResult]: + ) -> Iterable["_models.SBTopic"]: """Gets all the topics in a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :param skip: Skip is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skip @@ -964,53 +1111,56 @@ def list_by_namespace( Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBTopicListResult or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.SBTopicListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either SBTopic or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.SBTopic] + :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', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBTopicListResult] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[_models.SBTopicListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_namespace_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, - api_version=api_version, skip=skip, top=top, - template_url=self.list_by_namespace.metadata['url'], + api_version=api_version, + template_url=self.list_by_namespace.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_by_namespace_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - skip=skip, - top=top, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -1018,16 +1168,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("SBTopicListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1038,49 +1186,122 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_namespace.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics"} # type: ignore + list_by_namespace.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics" + } - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, namespace_name: str, topic_name: str, parameters: _models.SBTopic, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SBTopic: """Creates a topic in the specified namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param parameters: Parameters supplied to create a topic resource. + :param parameters: Parameters supplied to create a topic resource. Required. :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.SBTopic + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBTopic or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.SBTopic + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBTopic: + """Creates a topic in the specified namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param parameters: Parameters supplied to create a topic resource. Required. + :type 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: SBTopic, or the result of cls(response) + :return: SBTopic or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.SBTopic - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + parameters: Union[_models.SBTopic, IO], + **kwargs: Any + ) -> _models.SBTopic: + """Creates a topic in the specified namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param parameters: Parameters supplied to create a topic resource. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.SBTopic 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: SBTopic or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.SBTopic + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBTopic] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SBTopic] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'SBTopic') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBTopic") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -1090,18 +1311,18 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - 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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1109,67 +1330,65 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBTopic', pipeline_response) + deserialized = self._deserialize("SBTopic", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}"} # type: ignore - + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}" + } @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, topic_name: str, **kwargs: Any ) -> None: """Deletes a topic from the specified namespace and resource group. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, topic_name=topic_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1180,60 +1399,56 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}"} # type: ignore - + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}" + } @distributed_trace - def get( - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - **kwargs: Any - ) -> _models.SBTopic: + def get(self, resource_group_name: str, namespace_name: str, topic_name: str, **kwargs: Any) -> _models.SBTopic: """Returns a description for the specified topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBTopic, or the result of cls(response) + :return: SBTopic or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.SBTopic - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBTopic] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[_models.SBTopic] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, topic_name=topic_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1241,12 +1456,13 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBTopic', pipeline_response) + deserialized = self._deserialize("SBTopic", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/__init__.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/__init__.py index 221541a00fb6e..2e171d69863bf 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/__init__.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/__init__.py @@ -13,11 +13,14 @@ try: from ._patch import __all__ as _patch_all - from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import + from ._patch import * # pylint: disable=unused-wildcard-import except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['ServiceBusManagementClient'] + +__all__ = [ + "ServiceBusManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/_configuration.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/_configuration.py index 3c8663a0c0b60..8f3614615856f 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/_configuration.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from ._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential @@ -25,24 +31,19 @@ class ServiceBusManagementClientConfiguration(Configuration): # pylint: disable 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: Subscription credentials that uniquely identify a Microsoft Azure - subscription. The subscription ID forms part of the URI for every service call. + subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2018-01-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(ServiceBusManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + api_version: Literal["2018-01-01-preview"] = kwargs.pop("api_version", "2018-01-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -52,23 +53,21 @@ def __init__( 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-servicebus/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-servicebus/{}".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') + 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.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/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/_metadata.json b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/_metadata.json index 6a6601651a9e9..24e8066df6f54 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/_metadata.json +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_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\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ServiceBusManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"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\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ServiceBusManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"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\": [\"ServiceBusManagementClientConfiguration\"], \".._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\": [\"ServiceBusManagementClientConfiguration\"], \"..._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": "Subscription credentials that uniquely identify a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.", + "signature": "subscription_id: str,", + "description": "Subscription credentials that uniquely identify a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. 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": "Subscription credentials that uniquely identify a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.", + "description": "Subscription credentials that uniquely identify a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. Required.", "docstring_type": "str", "required": true } @@ -48,19 +48,19 @@ "service_client_specific": { "sync": { "api_version": { - "signature": "api_version=None, # type: Optional[str]", + "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=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false }, "profile": { - "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "signature": "profile: KnownProfiles=KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", "required": false @@ -111,4 +111,4 @@ "rules": "RulesOperations", "operations": "Operations" } -} \ No newline at end of file +} diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/_patch.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/_patch.py index 0ad201a8c586e..f7dd32510333d 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/_patch.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/_service_bus_management_client.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/_service_bus_management_client.py index fd3c7382e5a33..3d3c2144d7449 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/_service_bus_management_client.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/_service_bus_management_client.py @@ -9,20 +9,34 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from . import models +from . import models as _models +from .._serialization import Deserializer, Serializer from ._configuration import ServiceBusManagementClientConfiguration -from .operations import DisasterRecoveryConfigsOperations, EventHubsOperations, MigrationConfigsOperations, NamespacesOperations, Operations, PremiumMessagingRegionsOperations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, QueuesOperations, RegionsOperations, RulesOperations, SubscriptionsOperations, TopicsOperations +from .operations import ( + DisasterRecoveryConfigsOperations, + EventHubsOperations, + MigrationConfigsOperations, + NamespacesOperations, + Operations, + PremiumMessagingRegionsOperations, + PrivateEndpointConnectionsOperations, + PrivateLinkResourcesOperations, + QueuesOperations, + RegionsOperations, + RulesOperations, + SubscriptionsOperations, + TopicsOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class ServiceBusManagementClient: # pylint: disable=too-many-instance-attributes + +class ServiceBusManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Azure Service Bus client for managing Namespace, IPFilter Rules, VirtualNetworkRules and Zone Redundant. @@ -58,10 +72,10 @@ class ServiceBusManagementClient: # pylint: disable=too-many-instance-attribu :vartype rules: azure.mgmt.servicebus.v2018_01_01_preview.operations.RulesOperations :ivar operations: Operations operations :vartype operations: azure.mgmt.servicebus.v2018_01_01_preview.operations.Operations - :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: Subscription credentials that uniquely identify a Microsoft Azure - subscription. The subscription ID forms part of the URI for every service call. + subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -79,16 +93,16 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = ServiceBusManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = ServiceBusManagementClientConfiguration( + 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)} + 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.namespaces = NamespacesOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.namespaces = NamespacesOperations(self._client, self._config, self._serialize, self._deserialize) self.private_endpoint_connections = PrivateEndpointConnectionsOperations( self._client, self._config, self._serialize, self._deserialize ) @@ -98,40 +112,21 @@ def __init__( self.disaster_recovery_configs = DisasterRecoveryConfigsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.queues = QueuesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.topics = TopicsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.event_hubs = EventHubsOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.queues = QueuesOperations(self._client, self._config, self._serialize, self._deserialize) + self.topics = TopicsOperations(self._client, self._config, self._serialize, self._deserialize) + self.event_hubs = EventHubsOperations(self._client, self._config, self._serialize, self._deserialize) self.migration_configs = MigrationConfigsOperations( self._client, self._config, self._serialize, self._deserialize ) self.premium_messaging_regions = PremiumMessagingRegionsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.regions = RegionsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.subscriptions = SubscriptionsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.rules = RulesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize - ) - + self.regions = RegionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.subscriptions = SubscriptionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.rules = RulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - def _send_request( - self, - request: 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 @@ -140,7 +135,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 @@ -153,15 +148,12 @@ def _send_request( request_copy.url = self._client.format_url(request_copy.url) return self._client.send_request(request_copy, **kwargs) - def close(self): - # type: () -> None + def close(self) -> None: self._client.close() - def __enter__(self): - # type: () -> ServiceBusManagementClient + def __enter__(self) -> "ServiceBusManagementClient": self._client.__enter__() return self - def __exit__(self, *exc_details): - # type: (Any) -> None + def __exit__(self, *exc_details) -> None: self._client.__exit__(*exc_details) diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/_vendor.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/_vendor.py index 138f663c53a4e..9aad73fc743e7 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/_vendor.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_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/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/_version.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/_version.py index 920456322fa12..e5754a47ce68f 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/_version.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "8.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/__init__.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/__init__.py index e7dd87df1f939..530b8638dfd32 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/__init__.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/__init__.py @@ -10,11 +10,14 @@ try: from ._patch import __all__ as _patch_all - from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import + from ._patch import * # pylint: disable=unused-wildcard-import except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['ServiceBusManagementClient'] + +__all__ = [ + "ServiceBusManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/_configuration.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/_configuration.py index 6808f4a0adc0e..0699138d61e40 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/_configuration.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from .._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential @@ -25,24 +31,19 @@ class ServiceBusManagementClientConfiguration(Configuration): # pylint: disable 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: Subscription credentials that uniquely identify a Microsoft Azure - subscription. The subscription ID forms part of the URI for every service call. + subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2018-01-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(ServiceBusManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + api_version: Literal["2018-01-01-preview"] = kwargs.pop("api_version", "2018-01-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -52,22 +53,21 @@ def __init__( 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-servicebus/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-servicebus/{}".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/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/_patch.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/_patch.py index 0ad201a8c586e..f7dd32510333d 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/_patch.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/_service_bus_management_client.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/_service_bus_management_client.py index 14922a3686448..92898276110d3 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/_service_bus_management_client.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/_service_bus_management_client.py @@ -9,20 +9,34 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from .. import models +from .. import models as _models +from ..._serialization import Deserializer, Serializer from ._configuration import ServiceBusManagementClientConfiguration -from .operations import DisasterRecoveryConfigsOperations, EventHubsOperations, MigrationConfigsOperations, NamespacesOperations, Operations, PremiumMessagingRegionsOperations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, QueuesOperations, RegionsOperations, RulesOperations, SubscriptionsOperations, TopicsOperations +from .operations import ( + DisasterRecoveryConfigsOperations, + EventHubsOperations, + MigrationConfigsOperations, + NamespacesOperations, + Operations, + PremiumMessagingRegionsOperations, + PrivateEndpointConnectionsOperations, + PrivateLinkResourcesOperations, + QueuesOperations, + RegionsOperations, + RulesOperations, + SubscriptionsOperations, + TopicsOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class ServiceBusManagementClient: # pylint: disable=too-many-instance-attributes + +class ServiceBusManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Azure Service Bus client for managing Namespace, IPFilter Rules, VirtualNetworkRules and Zone Redundant. @@ -60,10 +74,10 @@ class ServiceBusManagementClient: # pylint: disable=too-many-instance-attribu :vartype rules: azure.mgmt.servicebus.v2018_01_01_preview.aio.operations.RulesOperations :ivar operations: Operations operations :vartype operations: azure.mgmt.servicebus.v2018_01_01_preview.aio.operations.Operations - :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: Subscription credentials that uniquely identify a Microsoft Azure - subscription. The subscription ID forms part of the URI for every service call. + subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -81,16 +95,16 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = ServiceBusManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = ServiceBusManagementClientConfiguration( + 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)} + 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.namespaces = NamespacesOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.namespaces = NamespacesOperations(self._client, self._config, self._serialize, self._deserialize) self.private_endpoint_connections = PrivateEndpointConnectionsOperations( self._client, self._config, self._serialize, self._deserialize ) @@ -100,40 +114,21 @@ def __init__( self.disaster_recovery_configs = DisasterRecoveryConfigsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.queues = QueuesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.topics = TopicsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.event_hubs = EventHubsOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.queues = QueuesOperations(self._client, self._config, self._serialize, self._deserialize) + self.topics = TopicsOperations(self._client, self._config, self._serialize, self._deserialize) + self.event_hubs = EventHubsOperations(self._client, self._config, self._serialize, self._deserialize) self.migration_configs = MigrationConfigsOperations( self._client, self._config, self._serialize, self._deserialize ) self.premium_messaging_regions = PremiumMessagingRegionsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.regions = RegionsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.subscriptions = SubscriptionsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.rules = RulesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize - ) - + self.regions = RegionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.subscriptions = SubscriptionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.rules = RulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(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 @@ -142,7 +137,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/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/__init__.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/__init__.py index a21798eafb6a6..7209ae0760257 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/__init__.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/__init__.py @@ -21,22 +21,23 @@ from ._operations import Operations from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'NamespacesOperations', - 'PrivateEndpointConnectionsOperations', - 'PrivateLinkResourcesOperations', - 'DisasterRecoveryConfigsOperations', - 'QueuesOperations', - 'TopicsOperations', - 'EventHubsOperations', - 'MigrationConfigsOperations', - 'PremiumMessagingRegionsOperations', - 'RegionsOperations', - 'SubscriptionsOperations', - 'RulesOperations', - 'Operations', + "NamespacesOperations", + "PrivateEndpointConnectionsOperations", + "PrivateLinkResourcesOperations", + "DisasterRecoveryConfigsOperations", + "QueuesOperations", + "TopicsOperations", + "EventHubsOperations", + "MigrationConfigsOperations", + "PremiumMessagingRegionsOperations", + "RegionsOperations", + "SubscriptionsOperations", + "RulesOperations", + "Operations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_disaster_recovery_configs_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_disaster_recovery_configs_operations.py index b5580e25977e2..06bb638aabdda 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_disaster_recovery_configs_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_disaster_recovery_configs_operations.py @@ -6,10 +6,19 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,27 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._disaster_recovery_configs_operations import build_break_pairing_request, build_check_name_availability_request, build_create_or_update_request, build_delete_request, build_fail_over_request, build_get_authorization_rule_request, build_get_request, build_list_authorization_rules_request, build_list_keys_request, build_list_request -T = TypeVar('T') +from ...operations._disaster_recovery_configs_operations import ( + build_break_pairing_request, + build_check_name_availability_request, + build_create_or_update_request, + build_delete_request, + build_fail_over_request, + build_get_authorization_rule_request, + build_get_request, + build_list_authorization_rules_request, + build_list_keys_request, + build_list_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class DisasterRecoveryConfigsOperations: """ .. warning:: @@ -43,41 +69,109 @@ def __init__(self, *args, **kwargs) -> None: 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 + @overload async def check_name_availability( self, resource_group_name: str, namespace_name: str, parameters: _models.CheckNameAvailability, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Check the give namespace name availability. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: Parameters to check availability of the given namespace name. + :param parameters: Parameters to check availability of the given namespace name. Required. :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.CheckNameAvailability + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckNameAvailabilityResult, or the result of cls(response) + :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.CheckNameAvailabilityResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters to check availability of the given namespace name. Required. + :type 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: CheckNameAvailabilityResult or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_name_availability( + self, + resource_group_name: str, + namespace_name: str, + parameters: Union[_models.CheckNameAvailability, IO], + **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters to check availability of the given namespace name. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.CheckNameAvailability 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: CheckNameAvailabilityResult or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.CheckNameAvailabilityResult] - - _json = self._serialize.body(parameters, 'CheckNameAvailability') + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CheckNameAvailabilityResult] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "CheckNameAvailability") request = build_check_name_availability_request( resource_group_name=resource_group_name, @@ -86,18 +180,18 @@ async def check_name_availability( 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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -105,74 +199,79 @@ async def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) + deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/CheckNameAvailability"} # type: ignore - + check_name_availability.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/CheckNameAvailability" + } @distributed_trace def list( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.ArmDisasterRecoveryListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ArmDisasterRecovery"]: """Gets all Alias(Disaster Recovery configurations). - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ArmDisasterRecoveryListResult or the result of - cls(response) + :return: An iterator like instance of either ArmDisasterRecovery or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.ArmDisasterRecoveryListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.ArmDisasterRecovery] + :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', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ArmDisasterRecoveryListResult] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[_models.ArmDisasterRecoveryListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -180,16 +279,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("ArmDisasterRecoveryListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -200,49 +297,126 @@ 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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs" + } - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, namespace_name: str, alias: str, parameters: _models.ArmDisasterRecovery, + *, + content_type: str = "application/json", **kwargs: Any ) -> Optional[_models.ArmDisasterRecovery]: """Creates or updates a new Alias(Disaster Recovery configuration). - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: str :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). + Required. :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.ArmDisasterRecovery + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ArmDisasterRecovery, or the result of cls(response) + :return: ArmDisasterRecovery or None or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.ArmDisasterRecovery or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + alias: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> Optional[_models.ArmDisasterRecovery]: + """Creates or updates a new Alias(Disaster Recovery configuration). + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: str + :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). + Required. + :type 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: ArmDisasterRecovery or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.ArmDisasterRecovery or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + alias: str, + parameters: Union[_models.ArmDisasterRecovery, IO], + **kwargs: Any + ) -> Optional[_models.ArmDisasterRecovery]: + """Creates or updates a new Alias(Disaster Recovery configuration). + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: str + :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). Is + either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.ArmDisasterRecovery 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: ArmDisasterRecovery or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.ArmDisasterRecovery or None + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ArmDisasterRecovery]] - - _json = self._serialize.body(parameters, 'ArmDisasterRecovery') + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.ArmDisasterRecovery]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ArmDisasterRecovery") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -252,18 +426,18 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - 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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -273,67 +447,67 @@ async def create_or_update( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ArmDisasterRecovery', pipeline_response) + deserialized = self._deserialize("ArmDisasterRecovery", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}"} # type: ignore - + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}" + } @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - alias: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, alias: str, **kwargs: Any ) -> None: """Deletes an Alias(Disaster Recovery configuration). - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: 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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, alias=alias, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -344,60 +518,60 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}"} # type: ignore - + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}" + } @distributed_trace_async async def get( - self, - resource_group_name: str, - namespace_name: str, - alias: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, alias: str, **kwargs: Any ) -> _models.ArmDisasterRecovery: """Retrieves Alias(Disaster Recovery configuration) for primary or secondary namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ArmDisasterRecovery, or the result of cls(response) + :return: ArmDisasterRecovery or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.ArmDisasterRecovery - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ArmDisasterRecovery] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[_models.ArmDisasterRecovery] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, alias=alias, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -405,68 +579,68 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ArmDisasterRecovery', pipeline_response) + deserialized = self._deserialize("ArmDisasterRecovery", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}" + } @distributed_trace_async async def break_pairing( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - alias: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, alias: str, **kwargs: Any ) -> None: """This operation disables the Disaster Recovery and stops replicating changes from primary to secondary namespaces. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: 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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_break_pairing_request( resource_group_name=resource_group_name, namespace_name=namespace_name, alias=alias, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.break_pairing.metadata['url'], + template_url=self.break_pairing.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -477,50 +651,127 @@ async def break_pairing( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - break_pairing.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/breakPairing"} # type: ignore - + break_pairing.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/breakPairing" + } - @distributed_trace_async + @overload async def fail_over( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, alias: str, parameters: Optional[_models.FailoverProperties] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> None: """Invokes GEO DR failover and reconfigure the alias to point to the secondary namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: str :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). Default value is None. :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.FailoverProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default 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: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def fail_over( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + namespace_name: str, + alias: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Invokes GEO DR failover and reconfigure the alias to point to the secondary namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: str + :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). + Default value is None. + :type 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: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def fail_over( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + namespace_name: str, + alias: str, + parameters: Optional[Union[_models.FailoverProperties, IO]] = None, + **kwargs: Any + ) -> None: + """Invokes GEO DR failover and reconfigure the alias to point to the secondary namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: str + :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). Is + either a model type or a IO type. Default value is None. + :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.FailoverProperties 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: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[None] - - if parameters is not None: - _json = self._serialize.body(parameters, 'FailoverProperties') + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "FailoverProperties") + else: + _json = None request = build_fail_over_request( resource_group_name=resource_group_name, @@ -530,18 +781,18 @@ async def fail_over( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, json=_json, - template_url=self.fail_over.metadata['url'], + content=_content, + template_url=self.fail_over.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -552,72 +803,75 @@ async def fail_over( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - fail_over.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/failover"} # type: ignore - + fail_over.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/failover" + } @distributed_trace def list_authorization_rules( - self, - resource_group_name: str, - namespace_name: str, - alias: str, - **kwargs: Any - ) -> AsyncIterable[_models.SBAuthorizationRuleListResult]: + self, resource_group_name: str, namespace_name: str, alias: str, **kwargs: Any + ) -> AsyncIterable["_models.SBAuthorizationRule"]: """Gets the authorization rules for a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of - cls(response) + :return: An iterator like instance of either SBAuthorizationRule or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRule] + :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', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRuleListResult] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[_models.SBAuthorizationRuleListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_authorization_rules_request( resource_group_name=resource_group_name, namespace_name=namespace_name, alias=alias, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_authorization_rules.metadata['url'], + template_url=self.list_authorization_rules.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_authorization_rules_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - alias=alias, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -625,16 +879,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("SBAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -645,48 +897,47 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_authorization_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules"} # type: ignore + list_authorization_rules.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules" + } @distributed_trace_async async def get_authorization_rule( - self, - resource_group_name: str, - namespace_name: str, - alias: str, - authorization_rule_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, alias: str, authorization_rule_name: str, **kwargs: Any ) -> _models.SBAuthorizationRule: """Gets an authorization rule for a namespace by rule name. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[_models.SBAuthorizationRule] = kwargs.pop("cls", None) - request = build_get_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -694,18 +945,17 @@ async def get_authorization_rule( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_authorization_rule.metadata['url'], + template_url=self.get_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -713,52 +963,52 @@ async def get_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules/{authorizationRuleName}"} # type: ignore - + get_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules/{authorizationRuleName}" + } @distributed_trace_async async def list_keys( - self, - resource_group_name: str, - namespace_name: str, - alias: str, - authorization_rule_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, alias: str, authorization_rule_name: str, **kwargs: Any ) -> _models.AccessKeys: """Gets the primary and secondary connection strings for the namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[_models.AccessKeys] = kwargs.pop("cls", None) - request = build_list_keys_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -766,18 +1016,17 @@ async def list_keys( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata['url'], + 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 + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -785,12 +1034,13 @@ async def list_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + deserialized = self._deserialize("AccessKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules/{authorizationRuleName}/listKeys"} # type: ignore - + list_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules/{authorizationRuleName}/listKeys" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_event_hubs_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_event_hubs_operations.py index 3a22807df094f..1d378bc5ea2c7 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_event_hubs_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_event_hubs_operations.py @@ -6,10 +6,19 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +29,15 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._event_hubs_operations import build_list_by_namespace_request -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class EventHubsOperations: """ .. warning:: @@ -42,64 +57,68 @@ def __init__(self, *args, **kwargs) -> None: 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_namespace( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.EventHubListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Eventhub"]: """Gets all the Event Hubs in a service bus Namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventHubListResult or the result of cls(response) + :return: An iterator like instance of either Eventhub or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.EventHubListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.Eventhub] + :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', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.EventHubListResult] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[_models.EventHubListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_namespace_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_namespace.metadata['url'], + template_url=self.list_by_namespace.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_by_namespace_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -107,16 +126,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("EventHubListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -127,8 +144,8 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_namespace.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/eventhubs"} # type: ignore + list_by_namespace.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/eventhubs" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_migration_configs_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_migration_configs_operations.py index e0e6603c19649..5aece43c796db 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_migration_configs_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_migration_configs_operations.py @@ -6,10 +6,19 @@ # 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, Union, cast +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod @@ -22,10 +31,23 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._migration_configs_operations import build_complete_migration_request, build_create_and_start_migration_request_initial, build_delete_request, build_get_request, build_list_request, build_revert_request -T = TypeVar('T') +from ...operations._migration_configs_operations import ( + build_complete_migration_request, + build_create_and_start_migration_request, + build_delete_request, + build_get_request, + build_list_request, + build_revert_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class MigrationConfigsOperations: """ .. warning:: @@ -45,65 +67,69 @@ def __init__(self, *args, **kwargs) -> None: 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, - namespace_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.MigrationConfigListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> AsyncIterable["_models.MigrationConfigProperties"]: """Gets all migrationConfigurations. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MigrationConfigListResult or the result of + :return: An iterator like instance of either MigrationConfigProperties or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.MigrationConfigListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.MigrationConfigProperties] + :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', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MigrationConfigListResult] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[_models.MigrationConfigListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -111,16 +137,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("MigrationConfigListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -131,35 +155,46 @@ 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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations" + } async def _create_and_start_migration_initial( self, resource_group_name: str, namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], - parameters: _models.MigrationConfigProperties, + config_name: Union[str, _models.MigrationConfigurationName], + parameters: Union[_models.MigrationConfigProperties, IO], **kwargs: Any ) -> Optional[_models.MigrationConfigProperties]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.MigrationConfigProperties]] - - _json = self._serialize.body(parameters, 'MigrationConfigProperties') - - request = build_create_and_start_migration_request_initial( + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.MigrationConfigProperties]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "MigrationConfigProperties") + + request = build_create_and_start_migration_request( resource_group_name=resource_group_name, namespace_name=namespace_name, config_name=config_name, @@ -167,57 +202,146 @@ async def _create_and_start_migration_initial( api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_and_start_migration_initial.metadata['url'], + content=_content, + template_url=self._create_and_start_migration_initial.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('MigrationConfigProperties', pipeline_response) + deserialized = self._deserialize("MigrationConfigProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_and_start_migration_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}"} # type: ignore + _create_and_start_migration_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}" + } + + @overload + async def begin_create_and_start_migration( + self, + resource_group_name: str, + namespace_name: str, + config_name: Union[str, _models.MigrationConfigurationName], + parameters: _models.MigrationConfigProperties, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.MigrationConfigProperties]: + """Creates Migration configuration and starts migration of entities from Standard to Premium + namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param config_name: The configuration name. Should always be "$default". "$default" Required. + :type config_name: str or + ~azure.mgmt.servicebus.v2018_01_01_preview.models.MigrationConfigurationName + :param parameters: Parameters required to create Migration Configuration. Required. + :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.MigrationConfigProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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 MigrationConfigProperties or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.servicebus.v2018_01_01_preview.models.MigrationConfigProperties] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_and_start_migration( + self, + resource_group_name: str, + namespace_name: str, + config_name: Union[str, _models.MigrationConfigurationName], + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.MigrationConfigProperties]: + """Creates Migration configuration and starts migration of entities from Standard to Premium + namespace. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param config_name: The configuration name. Should always be "$default". "$default" Required. + :type config_name: str or + ~azure.mgmt.servicebus.v2018_01_01_preview.models.MigrationConfigurationName + :param parameters: Parameters required to create Migration Configuration. Required. + :type 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 + :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 MigrationConfigProperties or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.servicebus.v2018_01_01_preview.models.MigrationConfigProperties] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_and_start_migration( self, resource_group_name: str, namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], - parameters: _models.MigrationConfigProperties, + config_name: Union[str, _models.MigrationConfigurationName], + parameters: Union[_models.MigrationConfigProperties, IO], **kwargs: Any ) -> AsyncLROPoller[_models.MigrationConfigProperties]: """Creates Migration configuration and starts migration of entities from Standard to Premium namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :type config_name: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.MigrationConfigurationName - :param parameters: Parameters required to create Migration Configuration. + :param parameters: Parameters required to create Migration Configuration. Is either a model + type or a IO type. Required. :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.MigrationConfigProperties + 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 @@ -230,114 +354,114 @@ async def begin_create_and_start_migration( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.servicebus.v2018_01_01_preview.models.MigrationConfigProperties] - :raises: ~azure.core.exceptions.HttpResponseError + :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-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.MigrationConfigProperties] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.MigrationConfigProperties] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._create_and_start_migration_initial( # type: ignore + raw_result = await self._create_and_start_migration_initial( resource_group_name=resource_group_name, namespace_name=namespace_name, config_name=config_name, parameters=parameters, 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): - deserialized = self._deserialize('MigrationConfigProperties', pipeline_response) + deserialized = self._deserialize("MigrationConfigProperties", 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 + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create_and_start_migration.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}"} # type: ignore + begin_create_and_start_migration.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}" + } @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], + config_name: Union[str, _models.MigrationConfigurationName], **kwargs: Any ) -> None: """Deletes a MigrationConfiguration. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :type config_name: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.MigrationConfigurationName :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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, config_name=config_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -348,61 +472,65 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}"} # type: ignore - + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}" + } @distributed_trace_async async def get( self, resource_group_name: str, namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], + config_name: Union[str, _models.MigrationConfigurationName], **kwargs: Any ) -> _models.MigrationConfigProperties: """Retrieves Migration Config. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :type config_name: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.MigrationConfigurationName :keyword callable cls: A custom type or function that will be passed the direct response - :return: MigrationConfigProperties, or the result of cls(response) + :return: MigrationConfigProperties or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.MigrationConfigProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MigrationConfigProperties] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[_models.MigrationConfigProperties] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, config_name=config_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -410,70 +538,74 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('MigrationConfigProperties', pipeline_response) + deserialized = self._deserialize("MigrationConfigProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}" + } @distributed_trace_async async def complete_migration( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], + config_name: Union[str, _models.MigrationConfigurationName], **kwargs: Any ) -> None: """This operation Completes Migration of entities by pointing the connection strings to Premium namespace and any entities created after the operation will be under Premium Namespace. CompleteMigration operation will fail when entity migration is in-progress. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :type config_name: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.MigrationConfigurationName :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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_complete_migration_request( resource_group_name=resource_group_name, namespace_name=namespace_name, config_name=config_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.complete_migration.metadata['url'], + template_url=self.complete_migration.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -484,61 +616,65 @@ async def complete_migration( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - complete_migration.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/upgrade"} # type: ignore - + complete_migration.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/upgrade" + } @distributed_trace_async async def revert( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], + config_name: Union[str, _models.MigrationConfigurationName], **kwargs: Any ) -> None: """This operation reverts Migration. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :type config_name: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.MigrationConfigurationName :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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_revert_request( resource_group_name=resource_group_name, namespace_name=namespace_name, config_name=config_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.revert.metadata['url'], + template_url=self.revert.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -549,5 +685,6 @@ async def revert( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - revert.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/revert"} # type: ignore - + revert.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/revert" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_namespaces_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_namespaces_operations.py index 9f0518438612b..9f82e16fb0583 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_namespaces_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_namespaces_operations.py @@ -6,10 +6,19 @@ # 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, Union, cast +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod @@ -22,10 +31,42 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._namespaces_operations import build_check_name_availability_request, build_create_or_update_authorization_rule_request, build_create_or_update_ip_filter_rule_request, build_create_or_update_network_rule_set_request, build_create_or_update_request_initial, build_create_or_update_virtual_network_rule_request, build_delete_authorization_rule_request, build_delete_ip_filter_rule_request, build_delete_request_initial, build_delete_virtual_network_rule_request, build_get_authorization_rule_request, build_get_ip_filter_rule_request, build_get_network_rule_set_request, build_get_request, build_get_virtual_network_rule_request, build_list_authorization_rules_request, build_list_by_resource_group_request, build_list_ip_filter_rules_request, build_list_keys_request, build_list_network_rule_sets_request, build_list_request, build_list_virtual_network_rules_request, build_migrate_request, build_regenerate_keys_request, build_update_request -T = TypeVar('T') +from ...operations._namespaces_operations import ( + build_check_name_availability_request, + build_create_or_update_authorization_rule_request, + build_create_or_update_ip_filter_rule_request, + build_create_or_update_network_rule_set_request, + build_create_or_update_request, + build_create_or_update_virtual_network_rule_request, + build_delete_authorization_rule_request, + build_delete_ip_filter_rule_request, + build_delete_request, + build_delete_virtual_network_rule_request, + build_get_authorization_rule_request, + build_get_ip_filter_rule_request, + build_get_network_rule_set_request, + build_get_request, + build_get_virtual_network_rule_request, + build_list_authorization_rules_request, + build_list_by_resource_group_request, + build_list_ip_filter_rules_request, + build_list_keys_request, + build_list_network_rule_sets_request, + build_list_request, + build_list_virtual_network_rules_request, + build_migrate_request, + build_regenerate_keys_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class NamespacesOperations: # pylint: disable=too-many-public-methods """ .. warning:: @@ -45,65 +86,68 @@ def __init__(self, *args, **kwargs) -> None: 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_ip_filter_rules( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.IpFilterRuleListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> AsyncIterable["_models.IpFilterRule"]: """Gets a list of IP Filter rules for a Namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IpFilterRuleListResult or the result of - cls(response) + :return: An iterator like instance of either IpFilterRule or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.IpFilterRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.IpFilterRule] + :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', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.IpFilterRuleListResult] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[_models.IpFilterRuleListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_ip_filter_rules_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_ip_filter_rules.metadata['url'], + template_url=self.list_ip_filter_rules.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_ip_filter_rules_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -111,16 +155,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("IpFilterRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -131,49 +173,123 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_ip_filter_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/ipfilterrules"} # type: ignore + list_ip_filter_rules.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/ipfilterrules" + } - @distributed_trace_async + @overload async def create_or_update_ip_filter_rule( self, resource_group_name: str, namespace_name: str, ip_filter_rule_name: str, parameters: _models.IpFilterRule, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.IpFilterRule: """Creates or updates an IpFilterRule for a Namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param ip_filter_rule_name: The IP Filter Rule name. + :param ip_filter_rule_name: The IP Filter Rule name. Required. :type ip_filter_rule_name: str - :param parameters: The Namespace IpFilterRule. + :param parameters: The Namespace IpFilterRule. Required. :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.IpFilterRule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: IpFilterRule, or the result of cls(response) + :return: IpFilterRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.IpFilterRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_ip_filter_rule( + self, + resource_group_name: str, + namespace_name: str, + ip_filter_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.IpFilterRule: + """Creates or updates an IpFilterRule for a Namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param ip_filter_rule_name: The IP Filter Rule name. Required. + :type ip_filter_rule_name: str + :param parameters: The Namespace IpFilterRule. Required. + :type 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: IpFilterRule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.IpFilterRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update_ip_filter_rule( + self, + resource_group_name: str, + namespace_name: str, + ip_filter_rule_name: str, + parameters: Union[_models.IpFilterRule, IO], + **kwargs: Any + ) -> _models.IpFilterRule: + """Creates or updates an IpFilterRule for a Namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param ip_filter_rule_name: The IP Filter Rule name. Required. + :type ip_filter_rule_name: str + :param parameters: The Namespace IpFilterRule. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.IpFilterRule 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: IpFilterRule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.IpFilterRule + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.IpFilterRule] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.IpFilterRule] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'IpFilterRule') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "IpFilterRule") request = build_create_or_update_ip_filter_rule_request( resource_group_name=resource_group_name, @@ -183,18 +299,18 @@ async def create_or_update_ip_filter_rule( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_ip_filter_rule.metadata['url'], + content=_content, + template_url=self.create_or_update_ip_filter_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -202,67 +318,67 @@ async def create_or_update_ip_filter_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('IpFilterRule', pipeline_response) + deserialized = self._deserialize("IpFilterRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_ip_filter_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/ipfilterrules/{ipFilterRuleName}"} # type: ignore - + create_or_update_ip_filter_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/ipfilterrules/{ipFilterRuleName}" + } @distributed_trace_async async def delete_ip_filter_rule( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - ip_filter_rule_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, ip_filter_rule_name: str, **kwargs: Any ) -> None: """Deletes an IpFilterRule for a Namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param ip_filter_rule_name: The IP Filter Rule name. + :param ip_filter_rule_name: The IP Filter Rule name. Required. :type ip_filter_rule_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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_ip_filter_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, ip_filter_rule_name=ip_filter_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_ip_filter_rule.metadata['url'], + template_url=self.delete_ip_filter_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -273,60 +389,60 @@ async def delete_ip_filter_rule( # pylint: disable=inconsistent-return-statemen if cls: return cls(pipeline_response, None, {}) - delete_ip_filter_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/ipfilterrules/{ipFilterRuleName}"} # type: ignore - + delete_ip_filter_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/ipfilterrules/{ipFilterRuleName}" + } @distributed_trace_async async def get_ip_filter_rule( - self, - resource_group_name: str, - namespace_name: str, - ip_filter_rule_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, ip_filter_rule_name: str, **kwargs: Any ) -> _models.IpFilterRule: """Gets an IpFilterRule for a Namespace by rule name. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param ip_filter_rule_name: The IP Filter Rule name. + :param ip_filter_rule_name: The IP Filter Rule name. Required. :type ip_filter_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: IpFilterRule, or the result of cls(response) + :return: IpFilterRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.IpFilterRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.IpFilterRule] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[_models.IpFilterRule] = kwargs.pop("cls", None) - request = build_get_ip_filter_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, ip_filter_rule_name=ip_filter_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_ip_filter_rule.metadata['url'], + template_url=self.get_ip_filter_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -334,64 +450,71 @@ async def get_ip_filter_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('IpFilterRule', pipeline_response) + deserialized = self._deserialize("IpFilterRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_ip_filter_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/ipfilterrules/{ipFilterRuleName}"} # type: ignore - + get_ip_filter_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/ipfilterrules/{ipFilterRuleName}" + } @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable[_models.SBNamespaceListResult]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.SBNamespace"]: """Gets all the available namespaces within the subscription, irrespective of the resource groups. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBNamespaceListResult or the result of - cls(response) + :return: An iterator like instance of either SBNamespace or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBNamespaceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBNamespace] + :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', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBNamespaceListResult] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[_models.SBNamespaceListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -399,16 +522,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("SBNamespaceListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -419,65 +540,67 @@ 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': "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/namespaces"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/namespaces"} @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.SBNamespaceListResult]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.SBNamespace"]: """Gets the available namespaces within a resource group. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. 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 SBNamespaceListResult or the result of - cls(response) + :return: An iterator like instance of either SBNamespace or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBNamespaceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBNamespace] + :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', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBNamespaceListResult] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[_models.SBNamespaceListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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'], + 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 + request.url = self._client.format_url(request.url) else: - - 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=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -485,16 +608,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("SBNamespaceListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -505,90 +626,173 @@ 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.ServiceBus/namespaces"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces" + } async def _create_or_update_initial( - self, - resource_group_name: str, - namespace_name: str, - parameters: _models.SBNamespace, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, parameters: Union[_models.SBNamespace, IO], **kwargs: Any ) -> Optional[_models.SBNamespace]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.SBNamespace]] - - _json = self._serialize.body(parameters, 'SBNamespace') - - request = build_create_or_update_request_initial( + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.SBNamespace]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBNamespace") + + request = build_create_or_update_request( resource_group_name=resource_group_name, namespace_name=namespace_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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('SBNamespace', pipeline_response) + deserialized = self._deserialize("SBNamespace", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('SBNamespace', pipeline_response) + deserialized = self._deserialize("SBNamespace", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}" + } - - @distributed_trace_async + @overload async def begin_create_or_update( self, resource_group_name: str, namespace_name: str, parameters: _models.SBNamespace, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.SBNamespace]: """Creates or updates a service namespace. Once created, this namespace's resource manifest is immutable. This operation is idempotent. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: Parameters supplied to create a namespace resource. + :param parameters: Parameters supplied to create a namespace resource. Required. :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBNamespace + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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 SBNamespace or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBNamespace] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.SBNamespace]: + """Creates or updates a service namespace. Once created, this namespace's resource manifest is + immutable. This operation is idempotent. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to create a namespace resource. Required. + :type 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 + :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 SBNamespace or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBNamespace] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, resource_group_name: str, namespace_name: str, parameters: Union[_models.SBNamespace, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.SBNamespace]: + """Creates or updates a service namespace. Once created, this namespace's resource manifest is + immutable. This operation is idempotent. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to create a namespace resource. Is either a model type + or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBNamespace 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 @@ -601,121 +805,115 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBNamespace] - :raises: ~azure.core.exceptions.HttpResponseError + :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-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBNamespace] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SBNamespace] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._create_or_update_initial( # type: ignore + raw_result = await self._create_or_update_initial( resource_group_name=resource_group_name, namespace_name=namespace_name, parameters=parameters, 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): - deserialized = self._deserialize('SBNamespace', pipeline_response) + deserialized = self._deserialize("SBNamespace", 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 + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, **kwargs: Any ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request_initial( + request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + 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 + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}" + } @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete(self, resource_group_name: str, namespace_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes an existing namespace. This operation also removes all associated resources under the namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_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. @@ -727,103 +925,98 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements 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: """ _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-01-preview")) # type: 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 + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, namespace_name=namespace_name, api_version=api_version, - 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 = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}" + } @distributed_trace_async - async def get( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> _models.SBNamespace: + async def get(self, resource_group_name: str, namespace_name: str, **kwargs: Any) -> _models.SBNamespace: """Gets a description for the specified namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBNamespace, or the result of cls(response) + :return: SBNamespace or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBNamespace - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBNamespace] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[_models.SBNamespace] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -831,51 +1024,124 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBNamespace', pipeline_response) + deserialized = self._deserialize("SBNamespace", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}" + } + + @overload + async def update( + self, + resource_group_name: str, + namespace_name: str, + parameters: _models.SBNamespaceUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> Optional[_models.SBNamespace]: + """Updates a service namespace. Once created, this namespace's resource manifest is immutable. + This operation is idempotent. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to update a namespace resource. Required. + :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBNamespaceUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBNamespace or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBNamespace or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> Optional[_models.SBNamespace]: + """Updates a service namespace. Once created, this namespace's resource manifest is immutable. + This operation is idempotent. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to update a namespace resource. Required. + :type 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: SBNamespace or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBNamespace or None + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def update( self, resource_group_name: str, namespace_name: str, - parameters: _models.SBNamespaceUpdateParameters, + parameters: Union[_models.SBNamespaceUpdateParameters, IO], **kwargs: Any ) -> Optional[_models.SBNamespace]: """Updates a service namespace. Once created, this namespace's resource manifest is immutable. This operation is idempotent. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: Parameters supplied to update a namespace resource. + :param parameters: Parameters supplied to update a namespace resource. Is either a model type + or a IO type. Required. :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBNamespaceUpdateParameters + 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: SBNamespace, or the result of cls(response) + :return: SBNamespace or None or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBNamespace or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.SBNamespace]] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.SBNamespace]] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'SBNamespaceUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBNamespaceUpdateParameters") request = build_update_request( resource_group_name=resource_group_name, @@ -884,18 +1150,18 @@ async def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -905,77 +1171,82 @@ async def update( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('SBNamespace', pipeline_response) + deserialized = self._deserialize("SBNamespace", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('SBNamespace', pipeline_response) + deserialized = self._deserialize("SBNamespace", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore - + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}" + } @distributed_trace def list_virtual_network_rules( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.VirtualNetworkRuleListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> AsyncIterable["_models.VirtualNetworkRule"]: """Gets a list of VirtualNetwork rules for a Namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either VirtualNetworkRuleListResult or the result of - cls(response) + :return: An iterator like instance of either VirtualNetworkRule or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.VirtualNetworkRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.VirtualNetworkRule] + :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', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualNetworkRuleListResult] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[_models.VirtualNetworkRuleListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_virtual_network_rules_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_virtual_network_rules.metadata['url'], + template_url=self.list_virtual_network_rules.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_virtual_network_rules_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -983,16 +1254,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("VirtualNetworkRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1003,11 +1272,71 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_virtual_network_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/virtualnetworkrules"} # type: ignore + list_virtual_network_rules.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/virtualnetworkrules" + } + + @overload + async def create_or_update_virtual_network_rule( + self, + resource_group_name: str, + namespace_name: str, + virtual_network_rule_name: str, + parameters: _models.VirtualNetworkRule, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.VirtualNetworkRule: + """Creates or updates an VirtualNetworkRule for a Namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param virtual_network_rule_name: The Virtual Network Rule name. Required. + :type virtual_network_rule_name: str + :param parameters: The Namespace VirtualNetworkRule. Required. + :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.VirtualNetworkRule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: VirtualNetworkRule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.VirtualNetworkRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_virtual_network_rule( + self, + resource_group_name: str, + namespace_name: str, + virtual_network_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.VirtualNetworkRule: + """Creates or updates an VirtualNetworkRule for a Namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param virtual_network_rule_name: The Virtual Network Rule name. Required. + :type virtual_network_rule_name: str + :param parameters: The Namespace VirtualNetworkRule. Required. + :type 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: VirtualNetworkRule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.VirtualNetworkRule + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def create_or_update_virtual_network_rule( @@ -1015,37 +1344,52 @@ async def create_or_update_virtual_network_rule( resource_group_name: str, namespace_name: str, virtual_network_rule_name: str, - parameters: _models.VirtualNetworkRule, + parameters: Union[_models.VirtualNetworkRule, IO], **kwargs: Any ) -> _models.VirtualNetworkRule: """Creates or updates an VirtualNetworkRule for a Namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param virtual_network_rule_name: The Virtual Network Rule name. + :param virtual_network_rule_name: The Virtual Network Rule name. Required. :type virtual_network_rule_name: str - :param parameters: The Namespace VirtualNetworkRule. - :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.VirtualNetworkRule + :param parameters: The Namespace VirtualNetworkRule. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.VirtualNetworkRule 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: VirtualNetworkRule, or the result of cls(response) + :return: VirtualNetworkRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.VirtualNetworkRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualNetworkRule] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.VirtualNetworkRule] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'VirtualNetworkRule') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "VirtualNetworkRule") request = build_create_or_update_virtual_network_rule_request( resource_group_name=resource_group_name, @@ -1055,18 +1399,18 @@ async def create_or_update_virtual_network_rule( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_virtual_network_rule.metadata['url'], + content=_content, + template_url=self.create_or_update_virtual_network_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1074,67 +1418,67 @@ async def create_or_update_virtual_network_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('VirtualNetworkRule', pipeline_response) + deserialized = self._deserialize("VirtualNetworkRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_virtual_network_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/virtualnetworkrules/{virtualNetworkRuleName}"} # type: ignore - + create_or_update_virtual_network_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/virtualnetworkrules/{virtualNetworkRuleName}" + } @distributed_trace_async async def delete_virtual_network_rule( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - virtual_network_rule_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, virtual_network_rule_name: str, **kwargs: Any ) -> None: """Deletes an VirtualNetworkRule for a Namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param virtual_network_rule_name: The Virtual Network Rule name. + :param virtual_network_rule_name: The Virtual Network Rule name. Required. :type virtual_network_rule_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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_virtual_network_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, virtual_network_rule_name=virtual_network_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_virtual_network_rule.metadata['url'], + template_url=self.delete_virtual_network_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1145,60 +1489,60 @@ async def delete_virtual_network_rule( # pylint: disable=inconsistent-return-st if cls: return cls(pipeline_response, None, {}) - delete_virtual_network_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/virtualnetworkrules/{virtualNetworkRuleName}"} # type: ignore - + delete_virtual_network_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/virtualnetworkrules/{virtualNetworkRuleName}" + } @distributed_trace_async async def get_virtual_network_rule( - self, - resource_group_name: str, - namespace_name: str, - virtual_network_rule_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, virtual_network_rule_name: str, **kwargs: Any ) -> _models.VirtualNetworkRule: """Gets an VirtualNetworkRule for a Namespace by rule name. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param virtual_network_rule_name: The Virtual Network Rule name. + :param virtual_network_rule_name: The Virtual Network Rule name. Required. :type virtual_network_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: VirtualNetworkRule, or the result of cls(response) + :return: VirtualNetworkRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.VirtualNetworkRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualNetworkRule] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[_models.VirtualNetworkRule] = kwargs.pop("cls", None) - request = build_get_virtual_network_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, virtual_network_rule_name=virtual_network_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_virtual_network_rule.metadata['url'], + template_url=self.get_virtual_network_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1206,74 +1550,79 @@ async def get_virtual_network_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('VirtualNetworkRule', pipeline_response) + deserialized = self._deserialize("VirtualNetworkRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_virtual_network_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/virtualnetworkrules/{virtualNetworkRuleName}"} # type: ignore - + get_virtual_network_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/virtualnetworkrules/{virtualNetworkRuleName}" + } @distributed_trace def list_authorization_rules( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.SBAuthorizationRuleListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> AsyncIterable["_models.SBAuthorizationRule"]: """Gets the authorization rules for a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of - cls(response) + :return: An iterator like instance of either SBAuthorizationRule or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRule] + :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', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRuleListResult] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[_models.SBAuthorizationRuleListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_authorization_rules_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_authorization_rules.metadata['url'], + template_url=self.list_authorization_rules.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_authorization_rules_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -1281,16 +1630,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("SBAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1301,49 +1648,124 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_authorization_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules"} # type: ignore + list_authorization_rules.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules" + } - @distributed_trace_async + @overload async def create_or_update_authorization_rule( self, resource_group_name: str, namespace_name: str, authorization_rule_name: str, parameters: _models.SBAuthorizationRule, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SBAuthorizationRule: """Creates or updates an authorization rule for a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: The shared access authorization rule. + :param parameters: The shared access authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBAuthorizationRule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates or updates an authorization rule for a namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Required. + :type 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: SBAuthorizationRule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: Union[_models.SBAuthorizationRule, IO], + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates or updates an authorization rule for a namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRule 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: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SBAuthorizationRule] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'SBAuthorizationRule') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBAuthorizationRule") request = build_create_or_update_authorization_rule_request( resource_group_name=resource_group_name, @@ -1353,18 +1775,18 @@ async def create_or_update_authorization_rule( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_authorization_rule.metadata['url'], + content=_content, + template_url=self.create_or_update_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1372,67 +1794,67 @@ async def create_or_update_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}"} # type: ignore - + create_or_update_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}" + } @distributed_trace_async async def delete_authorization_rule( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, authorization_rule_name: str, **kwargs: Any ) -> None: """Deletes a namespace authorization rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_authorization_rule.metadata['url'], + template_url=self.delete_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1443,60 +1865,60 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat if cls: return cls(pipeline_response, None, {}) - delete_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}"} # type: ignore - + delete_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}" + } @distributed_trace_async async def get_authorization_rule( - self, - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, authorization_rule_name: str, **kwargs: Any ) -> _models.SBAuthorizationRule: """Gets an authorization rule for a namespace by rule name. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[_models.SBAuthorizationRule] = kwargs.pop("cls", None) - request = build_get_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_authorization_rule.metadata['url'], + template_url=self.get_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1504,67 +1926,67 @@ async def get_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}"} # type: ignore - + get_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}" + } @distributed_trace_async async def list_keys( - self, - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, authorization_rule_name: str, **kwargs: Any ) -> _models.AccessKeys: """Gets the primary and secondary connection strings for the namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[_models.AccessKeys] = kwargs.pop("cls", None) - request = build_list_keys_request( resource_group_name=resource_group_name, namespace_name=namespace_name, authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata['url'], + 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 + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1572,54 +1994,131 @@ async def list_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + deserialized = self._deserialize("AccessKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/listKeys"} # type: ignore - + list_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/listKeys" + } - @distributed_trace_async + @overload async def regenerate_keys( self, resource_group_name: str, namespace_name: str, authorization_rule_name: str, parameters: _models.RegenerateAccessKeyParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.AccessKeys: """Regenerates the primary or secondary connection strings for the namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate the authorization rule. + :param parameters: Parameters supplied to regenerate the authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.RegenerateAccessKeyParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AccessKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AccessKeys: + """Regenerates the primary or secondary connection strings for the namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Required. + :type 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: AccessKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: Union[_models.RegenerateAccessKeyParameters, IO], + **kwargs: Any + ) -> _models.AccessKeys: + """Regenerates the primary or secondary connection strings for the namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Is either a model + type or a IO type. Required. + :type parameters: + ~azure.mgmt.servicebus.v2018_01_01_preview.models.RegenerateAccessKeyParameters 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: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AccessKeys] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RegenerateAccessKeyParameters") request = build_regenerate_keys_request( resource_group_name=resource_group_name, @@ -1629,18 +2128,18 @@ async def regenerate_keys( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_keys.metadata['url'], + content=_content, + template_url=self.regenerate_keys.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1648,62 +2147,110 @@ async def regenerate_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + deserialized = self._deserialize("AccessKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/regenerateKeys"} # type: ignore + regenerate_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/regenerateKeys" + } + + @overload + async def check_name_availability( + self, parameters: _models.CheckNameAvailability, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param parameters: Parameters to check availability of the given namespace name. Required. + :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.CheckNameAvailability + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckNameAvailabilityResult or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + async def check_name_availability( + self, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param parameters: Parameters to check availability of the given namespace name. Required. + :type 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: CheckNameAvailabilityResult or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def check_name_availability( - self, - parameters: _models.CheckNameAvailability, - **kwargs: Any + self, parameters: Union[_models.CheckNameAvailability, IO], **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Check the give namespace name availability. - :param parameters: Parameters to check availability of the given namespace name. - :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.CheckNameAvailability + :param parameters: Parameters to check availability of the given namespace name. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.CheckNameAvailability 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: CheckNameAvailabilityResult, or the result of cls(response) + :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.CheckNameAvailabilityResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.CheckNameAvailabilityResult] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CheckNameAvailabilityResult] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'CheckNameAvailability') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "CheckNameAvailability") 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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1711,50 +2258,119 @@ async def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) + deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/CheckNameAvailability"} # type: ignore + check_name_availability.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/CheckNameAvailability" + } - - @distributed_trace_async + @overload async def create_or_update_network_rule_set( self, resource_group_name: str, namespace_name: str, parameters: _models.NetworkRuleSet, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.NetworkRuleSet: """Create or update NetworkRuleSet for a Namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: The Namespace IpFilterRule. + :param parameters: The Namespace IpFilterRule. Required. :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.NetworkRuleSet + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: NetworkRuleSet or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.NetworkRuleSet + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_network_rule_set( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.NetworkRuleSet: + """Create or update NetworkRuleSet for a Namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: The Namespace IpFilterRule. Required. + :type 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: NetworkRuleSet or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.NetworkRuleSet + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update_network_rule_set( + self, + resource_group_name: str, + namespace_name: str, + parameters: Union[_models.NetworkRuleSet, IO], + **kwargs: Any + ) -> _models.NetworkRuleSet: + """Create or update NetworkRuleSet for a Namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: The Namespace IpFilterRule. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.NetworkRuleSet 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: NetworkRuleSet, or the result of cls(response) + :return: NetworkRuleSet or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.NetworkRuleSet - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.NetworkRuleSet] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.NetworkRuleSet] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'NetworkRuleSet') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "NetworkRuleSet") request = build_create_or_update_network_rule_set_request( resource_group_name=resource_group_name, @@ -1763,18 +2379,18 @@ async def create_or_update_network_rule_set( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_network_rule_set.metadata['url'], + content=_content, + template_url=self.create_or_update_network_rule_set.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1782,63 +2398,64 @@ async def create_or_update_network_rule_set( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('NetworkRuleSet', pipeline_response) + deserialized = self._deserialize("NetworkRuleSet", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_network_rule_set.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default"} # type: ignore - + create_or_update_network_rule_set.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default" + } @distributed_trace_async async def get_network_rule_set( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, **kwargs: Any ) -> _models.NetworkRuleSet: """Gets NetworkRuleSet for a Namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: NetworkRuleSet, or the result of cls(response) + :return: NetworkRuleSet or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.NetworkRuleSet - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.NetworkRuleSet] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[_models.NetworkRuleSet] = kwargs.pop("cls", None) - request = build_get_network_rule_set_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_network_rule_set.metadata['url'], + template_url=self.get_network_rule_set.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1846,74 +2463,79 @@ async def get_network_rule_set( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('NetworkRuleSet', pipeline_response) + deserialized = self._deserialize("NetworkRuleSet", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_network_rule_set.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default"} # type: ignore - + get_network_rule_set.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default" + } @distributed_trace def list_network_rule_sets( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.NetworkRuleSetListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> AsyncIterable["_models.NetworkRuleSet"]: """Gets list of NetworkRuleSet for a Namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either NetworkRuleSetListResult or the result of - cls(response) + :return: An iterator like instance of either NetworkRuleSet or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.NetworkRuleSetListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.NetworkRuleSet] + :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', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.NetworkRuleSetListResult] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[_models.NetworkRuleSetListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_network_rule_sets_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_network_rule_sets.metadata['url'], + template_url=self.list_network_rule_sets.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_network_rule_sets_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -1921,16 +2543,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("NetworkRuleSetListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1941,46 +2561,115 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_network_rule_sets.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets"} # type: ignore + list_network_rule_sets.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets" + } - @distributed_trace_async + @overload async def migrate( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, parameters: _models.SBNamespaceMigrate, + *, + content_type: str = "application/json", **kwargs: Any ) -> None: """This operation Migrate the given namespace to provided name type. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: Parameters supplied to migrate namespace type. + :param parameters: Parameters supplied to migrate namespace type. Required. :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBNamespaceMigrate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default 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: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def migrate( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """This operation Migrate the given namespace to provided name type. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to migrate namespace type. Required. + :type 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: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def migrate( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + namespace_name: str, + parameters: Union[_models.SBNamespaceMigrate, IO], + **kwargs: Any + ) -> None: + """This operation Migrate the given namespace to provided name type. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to migrate namespace type. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBNamespaceMigrate 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: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'SBNamespaceMigrate') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBNamespaceMigrate") request = build_migrate_request( resource_group_name=resource_group_name, @@ -1989,18 +2678,18 @@ async def migrate( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, json=_json, - template_url=self.migrate.metadata['url'], + content=_content, + template_url=self.migrate.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -2011,5 +2700,6 @@ async def migrate( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - migrate.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrate"} # type: ignore - + migrate.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrate" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_operations.py index f8ab560660787..49b19883879c7 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_operations.py @@ -6,10 +6,19 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +29,15 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._operations import build_list_request -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class Operations: """ .. warning:: @@ -42,52 +57,59 @@ def __init__(self, *args, **kwargs) -> None: 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 ServiceBus 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.servicebus.v2018_01_01_preview.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_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', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_request( - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -95,16 +117,14 @@ 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) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -115,8 +135,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.ServiceBus/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.ServiceBus/operations"} diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_patch.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_patch.py index 0ad201a8c586e..f7dd32510333d 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_patch.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_premium_messaging_regions_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_premium_messaging_regions_operations.py index 03b00dcbcaafa..443dba878258d 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_premium_messaging_regions_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_premium_messaging_regions_operations.py @@ -6,10 +6,19 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +29,15 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._premium_messaging_regions_operations import build_list_request -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class PremiumMessagingRegionsOperations: """ .. warning:: @@ -42,55 +57,61 @@ def __init__(self, *args, **kwargs) -> None: 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.PremiumMessagingRegionsListResult]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.PremiumMessagingRegions"]: """Gets the available premium messaging regions for servicebus. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PremiumMessagingRegionsListResult or the result of + :return: An iterator like instance of either PremiumMessagingRegions or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.PremiumMessagingRegionsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.PremiumMessagingRegions] + :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', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PremiumMessagingRegionsListResult] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[_models.PremiumMessagingRegionsListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -98,16 +119,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("PremiumMessagingRegionsListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -118,8 +137,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': "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/premiumMessagingRegions"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/premiumMessagingRegions"} diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_private_endpoint_connections_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_private_endpoint_connections_operations.py index 1e16f39f953a5..0d1fd2f72754a 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_private_endpoint_connections_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_private_endpoint_connections_operations.py @@ -6,10 +6,19 @@ # 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, Union, cast +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod @@ -22,10 +31,21 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._private_endpoint_connections_operations import build_create_or_update_request, build_delete_request_initial, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._private_endpoint_connections_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class PrivateEndpointConnectionsOperations: """ .. warning:: @@ -45,65 +65,69 @@ def __init__(self, *args, **kwargs) -> None: 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, - namespace_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.PrivateEndpointConnectionListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> AsyncIterable["_models.PrivateEndpointConnection"]: """Gets the available PrivateEndpointConnections within a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateEndpointConnectionListResult or the result - of cls(response) + :return: An iterator like instance of either PrivateEndpointConnection or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.PrivateEndpointConnectionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_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', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnectionListResult] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -111,16 +135,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -131,71 +153,148 @@ 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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections" + } - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, namespace_name: str, private_endpoint_connection_name: str, parameters: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Creates or updates PrivateEndpointConnections of service namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param private_endpoint_connection_name: The PrivateEndpointConnection name. Required. + :type private_endpoint_connection_name: str + :param parameters: Parameters supplied to update Status of PrivateEndPoint Connection to + namespace resource. Required. + :type parameters: ~azure.mgmt.servicebus.v2018_01_01_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 + :return: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + private_endpoint_connection_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Creates or updates PrivateEndpointConnections of service namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param private_endpoint_connection_name: The PrivateEndpointConnection name. Required. + :type private_endpoint_connection_name: str + :param parameters: Parameters supplied to update Status of PrivateEndPoint Connection to + namespace resource. Required. + :type 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: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + private_endpoint_connection_name: str, + parameters: Union[_models.PrivateEndpointConnection, IO], **kwargs: Any ) -> _models.PrivateEndpointConnection: """Creates or updates PrivateEndpointConnections of service namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param private_endpoint_connection_name: The PrivateEndpointConnection name. + :param private_endpoint_connection_name: The PrivateEndpointConnection name. Required. :type private_endpoint_connection_name: str :param parameters: Parameters supplied to update Status of PrivateEndPoint Connection to - namespace resource. + namespace resource. Is either a model type or a IO type. Required. :type parameters: ~azure.mgmt.servicebus.v2018_01_01_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 - :return: PrivateEndpointConnection, or the result of cls(response) + :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'PrivateEndpointConnection') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PrivateEndpointConnection") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, namespace_name=namespace_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.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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -204,83 +303,81 @@ async def create_or_update( 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 + return cls(pipeline_response, deserialized, {}) # type: ignore - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + return deserialized # type: ignore + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request_initial( + request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, - subscription_id=self._config.subscription_id, 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'], + 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 + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}" + } @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, namespace_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes an existing Private Endpoint Connection. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param private_endpoint_connection_name: The PrivateEndpointConnection name. + :param private_endpoint_connection_name: The PrivateEndpointConnection name. 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. @@ -292,108 +389,104 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements 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: """ _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-01-preview")) # type: 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 + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, namespace_name=namespace_name, private_endpoint_connection_name=private_endpoint_connection_name, api_version=api_version, - 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 = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}" + } @distributed_trace_async async def get( - self, - resource_group_name: str, - namespace_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> _models.PrivateEndpointConnection: """Gets a description for the specified Private Endpoint Connection. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param private_endpoint_connection_name: The PrivateEndpointConnection name. + :param private_endpoint_connection_name: The PrivateEndpointConnection name. 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.servicebus.v2018_01_01_preview.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_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'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -401,12 +494,13 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, 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.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_private_link_resources_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_private_link_resources_operations.py index 69a99ba81b3c5..121057ac2f0f9 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_private_link_resources_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_private_link_resources_operations.py @@ -6,9 +6,17 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Optional, TypeVar -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -19,9 +27,15 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._private_link_resources_operations import build_get_request -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class PrivateLinkResourcesOperations: """ .. warning:: @@ -41,54 +55,53 @@ def __init__(self, *args, **kwargs) -> None: 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, - namespace_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, **kwargs: Any ) -> _models.PrivateLinkResourcesListResult: """Gets lists of resources that supports Privatelinks. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateLinkResourcesListResult, or the result of cls(response) + :return: PrivateLinkResourcesListResult or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.PrivateLinkResourcesListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateLinkResourcesListResult] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[_models.PrivateLinkResourcesListResult] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -96,12 +109,13 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateLinkResourcesListResult', pipeline_response) + deserialized = self._deserialize("PrivateLinkResourcesListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateLinkResources"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateLinkResources" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_queues_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_queues_operations.py index b62f75b67b4b0..56eded91efc5b 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_queues_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_queues_operations.py @@ -6,10 +6,19 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,27 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._queues_operations import build_create_or_update_authorization_rule_request, build_create_or_update_request, build_delete_authorization_rule_request, build_delete_request, build_get_authorization_rule_request, build_get_request, build_list_authorization_rules_request, build_list_by_namespace_request, build_list_keys_request, build_regenerate_keys_request -T = TypeVar('T') +from ...operations._queues_operations import ( + build_create_or_update_authorization_rule_request, + build_create_or_update_request, + build_delete_authorization_rule_request, + build_delete_request, + build_get_authorization_rule_request, + build_get_request, + build_list_authorization_rules_request, + build_list_by_namespace_request, + build_list_keys_request, + build_regenerate_keys_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class QueuesOperations: """ .. warning:: @@ -43,70 +69,71 @@ def __init__(self, *args, **kwargs) -> None: 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_authorization_rules( - self, - resource_group_name: str, - namespace_name: str, - queue_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.SBAuthorizationRuleListResult]: + self, resource_group_name: str, namespace_name: str, queue_name: str, **kwargs: Any + ) -> AsyncIterable["_models.SBAuthorizationRule"]: """Gets all authorization rules for a queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of - cls(response) + :return: An iterator like instance of either SBAuthorizationRule or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRule] + :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', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRuleListResult] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[_models.SBAuthorizationRuleListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_authorization_rules_request( resource_group_name=resource_group_name, namespace_name=namespace_name, queue_name=queue_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_authorization_rules.metadata['url'], + template_url=self.list_authorization_rules.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_authorization_rules_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - queue_name=queue_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -114,16 +141,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("SBAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -134,13 +159,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_authorization_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules"} # type: ignore + list_authorization_rules.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules" + } - @distributed_trace_async + @overload async def create_or_update_authorization_rule( self, resource_group_name: str, @@ -148,38 +173,119 @@ async def create_or_update_authorization_rule( queue_name: str, authorization_rule_name: str, parameters: _models.SBAuthorizationRule, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SBAuthorizationRule: """Creates an authorization rule for a queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: The shared access authorization rule. + :param parameters: The shared access authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBAuthorizationRule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates an authorization rule for a queue. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Required. + :type 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: SBAuthorizationRule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: Union[_models.SBAuthorizationRule, IO], + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates an authorization rule for a queue. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRule 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: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SBAuthorizationRule] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'SBAuthorizationRule') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBAuthorizationRule") request = build_create_or_update_authorization_rule_request( resource_group_name=resource_group_name, @@ -190,18 +296,18 @@ async def create_or_update_authorization_rule( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_authorization_rule.metadata['url'], + content=_content, + template_url=self.create_or_update_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -209,15 +315,16 @@ async def create_or_update_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}"} # type: ignore - + create_or_update_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}" + } @distributed_trace_async async def delete_authorization_rule( # pylint: disable=inconsistent-return-statements @@ -230,31 +337,35 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat ) -> None: """Deletes a queue authorization rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -262,18 +373,17 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_authorization_rule.metadata['url'], + template_url=self.delete_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -284,8 +394,9 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat if cls: return cls(pipeline_response, None, {}) - delete_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}"} # type: ignore - + delete_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}" + } @distributed_trace_async async def get_authorization_rule( @@ -298,31 +409,35 @@ async def get_authorization_rule( ) -> _models.SBAuthorizationRule: """Gets an authorization rule for a queue by rule name. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[_models.SBAuthorizationRule] = kwargs.pop("cls", None) - request = build_get_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -330,18 +445,17 @@ async def get_authorization_rule( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_authorization_rule.metadata['url'], + template_url=self.get_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -349,15 +463,16 @@ async def get_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}"} # type: ignore - + get_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}" + } @distributed_trace_async async def list_keys( @@ -370,31 +485,35 @@ async def list_keys( ) -> _models.AccessKeys: """Primary and secondary connection strings to the queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[_models.AccessKeys] = kwargs.pop("cls", None) - request = build_list_keys_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -402,18 +521,17 @@ async def list_keys( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata['url'], + 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 + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -421,17 +539,18 @@ async def list_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + deserialized = self._deserialize("AccessKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/ListKeys"} # type: ignore - + list_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/ListKeys" + } - @distributed_trace_async + @overload async def regenerate_keys( self, resource_group_name: str, @@ -439,39 +558,121 @@ async def regenerate_keys( queue_name: str, authorization_rule_name: str, parameters: _models.RegenerateAccessKeyParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.AccessKeys: """Regenerates the primary or secondary connection strings to the queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate the authorization rule. + :param parameters: Parameters supplied to regenerate the authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.RegenerateAccessKeyParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AccessKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AccessKeys: + """Regenerates the primary or secondary connection strings to the queue. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Required. + :type 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: AccessKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: Union[_models.RegenerateAccessKeyParameters, IO], + **kwargs: Any + ) -> _models.AccessKeys: + """Regenerates the primary or secondary connection strings to the queue. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Is either a model + type or a IO type. Required. + :type parameters: + ~azure.mgmt.servicebus.v2018_01_01_preview.models.RegenerateAccessKeyParameters 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: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AccessKeys] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RegenerateAccessKeyParameters") request = build_regenerate_keys_request( resource_group_name=resource_group_name, @@ -482,18 +683,18 @@ async def regenerate_keys( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_keys.metadata['url'], + content=_content, + template_url=self.regenerate_keys.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -501,15 +702,16 @@ async def regenerate_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + deserialized = self._deserialize("AccessKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/regenerateKeys"} # type: ignore - + regenerate_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/regenerateKeys" + } @distributed_trace def list_by_namespace( @@ -519,12 +721,12 @@ def list_by_namespace( skip: Optional[int] = None, top: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable[_models.SBQueueListResult]: + ) -> AsyncIterable["_models.SBQueue"]: """Gets the queues within a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :param skip: Skip is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skip @@ -534,53 +736,59 @@ def list_by_namespace( Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBQueueListResult or the result of cls(response) + :return: An iterator like instance of either SBQueue or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBQueueListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBQueue] + :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', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBQueueListResult] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[_models.SBQueueListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_namespace_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, - api_version=api_version, skip=skip, top=top, - template_url=self.list_by_namespace.metadata['url'], + api_version=api_version, + template_url=self.list_by_namespace.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_by_namespace_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - skip=skip, - top=top, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -588,16 +796,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("SBQueueListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -608,49 +814,124 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_namespace.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues"} # type: ignore + list_by_namespace.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues" + } - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, namespace_name: str, queue_name: str, parameters: _models.SBQueue, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SBQueue: """Creates or updates a Service Bus queue. This operation is idempotent. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param parameters: Parameters supplied to create or update a queue resource. + :param parameters: Parameters supplied to create or update a queue resource. Required. :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBQueue + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBQueue or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBQueue: + """Creates or updates a Service Bus queue. This operation is idempotent. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param parameters: Parameters supplied to create or update a queue resource. Required. + :type 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: SBQueue or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + parameters: Union[_models.SBQueue, IO], + **kwargs: Any + ) -> _models.SBQueue: + """Creates or updates a Service Bus queue. This operation is idempotent. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param parameters: Parameters supplied to create or update a queue resource. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBQueue 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: SBQueue, or the result of cls(response) + :return: SBQueue or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBQueue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBQueue] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SBQueue] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'SBQueue') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBQueue") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -660,18 +941,18 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - 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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -679,67 +960,67 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBQueue', pipeline_response) + deserialized = self._deserialize("SBQueue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}"} # type: ignore - + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}" + } @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - queue_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, queue_name: str, **kwargs: Any ) -> None: """Deletes a queue from the specified namespace in a resource group. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, queue_name=queue_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -750,60 +1031,60 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}"} # type: ignore - + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}" + } @distributed_trace_async async def get( - self, - resource_group_name: str, - namespace_name: str, - queue_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, queue_name: str, **kwargs: Any ) -> _models.SBQueue: """Returns a description for the specified queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBQueue, or the result of cls(response) + :return: SBQueue or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBQueue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBQueue] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[_models.SBQueue] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, queue_name=queue_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -811,12 +1092,13 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBQueue', pipeline_response) + deserialized = self._deserialize("SBQueue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_regions_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_regions_operations.py index f946843d4e8bf..413939a86dd5f 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_regions_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_regions_operations.py @@ -6,10 +6,19 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +29,15 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._regions_operations import build_list_by_sku_request -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class RegionsOperations: """ .. warning:: @@ -42,60 +57,64 @@ def __init__(self, *args, **kwargs) -> None: 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_sku( - self, - sku: str, - **kwargs: Any - ) -> AsyncIterable[_models.PremiumMessagingRegionsListResult]: + def list_by_sku(self, sku: str, **kwargs: Any) -> AsyncIterable["_models.PremiumMessagingRegions"]: """Gets the available Regions for a given sku. - :param sku: The sku type. + :param sku: The sku type. Required. :type sku: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PremiumMessagingRegionsListResult or the result of + :return: An iterator like instance of either PremiumMessagingRegions or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.PremiumMessagingRegionsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.PremiumMessagingRegions] + :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', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PremiumMessagingRegionsListResult] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[_models.PremiumMessagingRegionsListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_sku_request( - subscription_id=self._config.subscription_id, sku=sku, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_sku.metadata['url'], + template_url=self.list_by_sku.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_by_sku_request( - subscription_id=self._config.subscription_id, - sku=sku, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -103,16 +122,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("PremiumMessagingRegionsListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -123,8 +140,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_sku.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/sku/{sku}/regions"} # type: ignore + list_by_sku.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/sku/{sku}/regions"} diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_rules_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_rules_operations.py index 77b438181854f..2a1d6ebe021bf 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_rules_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_rules_operations.py @@ -6,10 +6,19 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,21 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._rules_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_by_subscriptions_request -T = TypeVar('T') +from ...operations._rules_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_subscriptions_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class RulesOperations: """ .. warning:: @@ -43,7 +63,6 @@ def __init__(self, *args, **kwargs) -> None: 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_subscriptions( self, @@ -54,16 +73,16 @@ def list_by_subscriptions( skip: Optional[int] = None, top: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable[_models.RuleListResult]: + ) -> AsyncIterable["_models.Rule"]: """List all the rules within given topic-subscription. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str :param skip: Skip is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skip @@ -73,57 +92,61 @@ def list_by_subscriptions( Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RuleListResult or the result of cls(response) + :return: An iterator like instance of either Rule or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.RuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.Rule] + :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', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.RuleListResult] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[_models.RuleListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscriptions_request( resource_group_name=resource_group_name, namespace_name=namespace_name, topic_name=topic_name, subscription_name=subscription_name, subscription_id=self._config.subscription_id, - api_version=api_version, skip=skip, top=top, - template_url=self.list_by_subscriptions.metadata['url'], + api_version=api_version, + template_url=self.list_by_subscriptions.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_by_subscriptions_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - topic_name=topic_name, - subscription_name=subscription_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - skip=skip, - top=top, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -131,16 +154,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("RuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -151,13 +172,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_subscriptions.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules"} # type: ignore + list_by_subscriptions.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules" + } - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, @@ -166,40 +187,127 @@ async def create_or_update( subscription_name: str, rule_name: str, parameters: _models.Rule, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.Rule: """Creates a new rule and updates an existing rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str - :param rule_name: The rule name. + :param rule_name: The rule name. Required. :type rule_name: str - :param parameters: Parameters supplied to create a rule. + :param parameters: Parameters supplied to create a rule. Required. :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.Rule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Rule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.Rule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Rule: + """Creates a new rule and updates an existing rule. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param rule_name: The rule name. Required. + :type rule_name: str + :param parameters: Parameters supplied to create a rule. Required. + :type 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: Rule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.Rule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + rule_name: str, + parameters: Union[_models.Rule, IO], + **kwargs: Any + ) -> _models.Rule: + """Creates a new rule and updates an existing rule. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param rule_name: The rule name. Required. + :type rule_name: str + :param parameters: Parameters supplied to create a rule. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.Rule 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: Rule, or the result of cls(response) + :return: Rule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.Rule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.Rule] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Rule] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'Rule') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Rule") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -211,18 +319,18 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - 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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -230,15 +338,16 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Rule', pipeline_response) + deserialized = self._deserialize("Rule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}"} # type: ignore - + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}" + } @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -252,33 +361,37 @@ async def delete( # pylint: disable=inconsistent-return-statements ) -> None: """Deletes an existing rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str - :param rule_name: The rule name. + :param rule_name: The rule name. Required. :type rule_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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -287,18 +400,17 @@ async def delete( # pylint: disable=inconsistent-return-statements rule_name=rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -309,8 +421,9 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}"} # type: ignore - + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}" + } @distributed_trace_async async def get( @@ -324,33 +437,37 @@ async def get( ) -> _models.Rule: """Retrieves the description for the specified rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str - :param rule_name: The rule name. + :param rule_name: The rule name. Required. :type rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Rule, or the result of cls(response) + :return: Rule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.Rule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Rule] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[_models.Rule] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -359,18 +476,17 @@ async def get( rule_name=rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -378,12 +494,13 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Rule', pipeline_response) + deserialized = self._deserialize("Rule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_subscriptions_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_subscriptions_operations.py index 5c61d6d6e7f8e..81a1910ffb68d 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_subscriptions_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_subscriptions_operations.py @@ -6,10 +6,19 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,21 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._subscriptions_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_by_topic_request -T = TypeVar('T') +from ...operations._subscriptions_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_topic_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class SubscriptionsOperations: """ .. warning:: @@ -43,7 +63,6 @@ def __init__(self, *args, **kwargs) -> None: 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_topic( self, @@ -53,14 +72,14 @@ def list_by_topic( skip: Optional[int] = None, top: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable[_models.SBSubscriptionListResult]: + ) -> AsyncIterable["_models.SBSubscription"]: """List all the subscriptions under a specified topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str :param skip: Skip is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skip @@ -70,56 +89,60 @@ def list_by_topic( Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBSubscriptionListResult or the result of - cls(response) + :return: An iterator like instance of either SBSubscription or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBSubscriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBSubscription] + :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', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBSubscriptionListResult] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[_models.SBSubscriptionListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_topic_request( resource_group_name=resource_group_name, namespace_name=namespace_name, topic_name=topic_name, subscription_id=self._config.subscription_id, - api_version=api_version, skip=skip, top=top, - template_url=self.list_by_topic.metadata['url'], + api_version=api_version, + template_url=self.list_by_topic.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_by_topic_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - topic_name=topic_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - skip=skip, - top=top, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -127,16 +150,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("SBSubscriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -147,13 +168,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_topic.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions"} # type: ignore + list_by_topic.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions" + } - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, @@ -161,38 +182,119 @@ async def create_or_update( topic_name: str, subscription_name: str, parameters: _models.SBSubscription, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SBSubscription: """Creates a topic subscription. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str - :param parameters: Parameters supplied to create a subscription resource. + :param parameters: Parameters supplied to create a subscription resource. Required. :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBSubscription + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBSubscription, or the result of cls(response) + :return: SBSubscription or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBSubscription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBSubscription: + """Creates a topic subscription. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param parameters: Parameters supplied to create a subscription resource. Required. + :type 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: SBSubscription or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBSubscription + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + parameters: Union[_models.SBSubscription, IO], + **kwargs: Any + ) -> _models.SBSubscription: + """Creates a topic subscription. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param parameters: Parameters supplied to create a subscription resource. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBSubscription 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: SBSubscription or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBSubscription + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBSubscription] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SBSubscription] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'SBSubscription') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBSubscription") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -203,18 +305,18 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - 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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -222,52 +324,52 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBSubscription', pipeline_response) + deserialized = self._deserialize("SBSubscription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}"} # type: ignore - + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}" + } @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - subscription_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, topic_name: str, subscription_name: str, **kwargs: Any ) -> None: """Deletes a subscription from the specified topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -275,18 +377,17 @@ async def delete( # pylint: disable=inconsistent-return-statements subscription_name=subscription_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -297,45 +398,45 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}"} # type: ignore - + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}" + } @distributed_trace_async async def get( - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - subscription_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, topic_name: str, subscription_name: str, **kwargs: Any ) -> _models.SBSubscription: """Returns a subscription description for the specified topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBSubscription, or the result of cls(response) + :return: SBSubscription or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBSubscription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBSubscription] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[_models.SBSubscription] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -343,18 +444,17 @@ async def get( subscription_name=subscription_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -362,12 +462,13 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBSubscription', pipeline_response) + deserialized = self._deserialize("SBSubscription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_topics_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_topics_operations.py index e1551fb4e9f6b..465aee4e3863a 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_topics_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_topics_operations.py @@ -6,10 +6,19 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,27 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._topics_operations import build_create_or_update_authorization_rule_request, build_create_or_update_request, build_delete_authorization_rule_request, build_delete_request, build_get_authorization_rule_request, build_get_request, build_list_authorization_rules_request, build_list_by_namespace_request, build_list_keys_request, build_regenerate_keys_request -T = TypeVar('T') +from ...operations._topics_operations import ( + build_create_or_update_authorization_rule_request, + build_create_or_update_request, + build_delete_authorization_rule_request, + build_delete_request, + build_get_authorization_rule_request, + build_get_request, + build_list_authorization_rules_request, + build_list_by_namespace_request, + build_list_keys_request, + build_regenerate_keys_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class TopicsOperations: """ .. warning:: @@ -43,70 +69,71 @@ def __init__(self, *args, **kwargs) -> None: 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_authorization_rules( - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.SBAuthorizationRuleListResult]: + self, resource_group_name: str, namespace_name: str, topic_name: str, **kwargs: Any + ) -> AsyncIterable["_models.SBAuthorizationRule"]: """Gets authorization rules for a topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of - cls(response) + :return: An iterator like instance of either SBAuthorizationRule or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRule] + :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', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRuleListResult] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[_models.SBAuthorizationRuleListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_authorization_rules_request( resource_group_name=resource_group_name, namespace_name=namespace_name, topic_name=topic_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_authorization_rules.metadata['url'], + template_url=self.list_authorization_rules.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_authorization_rules_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - topic_name=topic_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -114,16 +141,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("SBAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -134,13 +159,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_authorization_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules"} # type: ignore + list_authorization_rules.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules" + } - @distributed_trace_async + @overload async def create_or_update_authorization_rule( self, resource_group_name: str, @@ -148,38 +173,119 @@ async def create_or_update_authorization_rule( topic_name: str, authorization_rule_name: str, parameters: _models.SBAuthorizationRule, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SBAuthorizationRule: """Creates an authorization rule for the specified topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: The shared access authorization rule. + :param parameters: The shared access authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBAuthorizationRule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates an authorization rule for the specified topic. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Required. + :type 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: SBAuthorizationRule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: Union[_models.SBAuthorizationRule, IO], + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates an authorization rule for the specified topic. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRule 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: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SBAuthorizationRule] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'SBAuthorizationRule') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBAuthorizationRule") request = build_create_or_update_authorization_rule_request( resource_group_name=resource_group_name, @@ -190,18 +296,18 @@ async def create_or_update_authorization_rule( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_authorization_rule.metadata['url'], + content=_content, + template_url=self.create_or_update_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -209,15 +315,16 @@ async def create_or_update_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}"} # type: ignore - + create_or_update_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}" + } @distributed_trace_async async def get_authorization_rule( @@ -230,31 +337,35 @@ async def get_authorization_rule( ) -> _models.SBAuthorizationRule: """Returns the specified authorization rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[_models.SBAuthorizationRule] = kwargs.pop("cls", None) - request = build_get_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -262,18 +373,17 @@ async def get_authorization_rule( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_authorization_rule.metadata['url'], + template_url=self.get_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -281,15 +391,16 @@ async def get_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}"} # type: ignore - + get_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}" + } @distributed_trace_async async def delete_authorization_rule( # pylint: disable=inconsistent-return-statements @@ -302,31 +413,35 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat ) -> None: """Deletes a topic authorization rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -334,18 +449,17 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_authorization_rule.metadata['url'], + template_url=self.delete_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -356,8 +470,9 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat if cls: return cls(pipeline_response, None, {}) - delete_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}"} # type: ignore - + delete_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}" + } @distributed_trace_async async def list_keys( @@ -370,31 +485,35 @@ async def list_keys( ) -> _models.AccessKeys: """Gets the primary and secondary connection strings for the topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[_models.AccessKeys] = kwargs.pop("cls", None) - request = build_list_keys_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -402,18 +521,17 @@ async def list_keys( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata['url'], + 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 + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -421,17 +539,18 @@ async def list_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + deserialized = self._deserialize("AccessKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/ListKeys"} # type: ignore - + list_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/ListKeys" + } - @distributed_trace_async + @overload async def regenerate_keys( self, resource_group_name: str, @@ -439,39 +558,121 @@ async def regenerate_keys( topic_name: str, authorization_rule_name: str, parameters: _models.RegenerateAccessKeyParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.AccessKeys: """Regenerates primary or secondary connection strings for the topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate the authorization rule. + :param parameters: Parameters supplied to regenerate the authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.RegenerateAccessKeyParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AccessKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AccessKeys: + """Regenerates primary or secondary connection strings for the topic. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Required. + :type 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: AccessKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: Union[_models.RegenerateAccessKeyParameters, IO], + **kwargs: Any + ) -> _models.AccessKeys: + """Regenerates primary or secondary connection strings for the topic. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Is either a model + type or a IO type. Required. + :type parameters: + ~azure.mgmt.servicebus.v2018_01_01_preview.models.RegenerateAccessKeyParameters 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: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AccessKeys] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RegenerateAccessKeyParameters") request = build_regenerate_keys_request( resource_group_name=resource_group_name, @@ -482,18 +683,18 @@ async def regenerate_keys( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_keys.metadata['url'], + content=_content, + template_url=self.regenerate_keys.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -501,15 +702,16 @@ async def regenerate_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + deserialized = self._deserialize("AccessKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/regenerateKeys"} # type: ignore - + regenerate_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/regenerateKeys" + } @distributed_trace def list_by_namespace( @@ -519,12 +721,12 @@ def list_by_namespace( skip: Optional[int] = None, top: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable[_models.SBTopicListResult]: + ) -> AsyncIterable["_models.SBTopic"]: """Gets all the topics in a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :param skip: Skip is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skip @@ -534,53 +736,59 @@ def list_by_namespace( Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBTopicListResult or the result of cls(response) + :return: An iterator like instance of either SBTopic or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBTopicListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBTopic] + :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', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBTopicListResult] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[_models.SBTopicListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_namespace_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, - api_version=api_version, skip=skip, top=top, - template_url=self.list_by_namespace.metadata['url'], + api_version=api_version, + template_url=self.list_by_namespace.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_by_namespace_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - skip=skip, - top=top, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -588,16 +796,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("SBTopicListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -608,49 +814,124 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_namespace.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics"} # type: ignore + list_by_namespace.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics" + } - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, namespace_name: str, topic_name: str, parameters: _models.SBTopic, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SBTopic: """Creates a topic in the specified namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param parameters: Parameters supplied to create a topic resource. + :param parameters: Parameters supplied to create a topic resource. Required. :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBTopic + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBTopic or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBTopic + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBTopic: + """Creates a topic in the specified namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param parameters: Parameters supplied to create a topic resource. Required. + :type 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: SBTopic or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBTopic + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + parameters: Union[_models.SBTopic, IO], + **kwargs: Any + ) -> _models.SBTopic: + """Creates a topic in the specified namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param parameters: Parameters supplied to create a topic resource. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBTopic 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: SBTopic, or the result of cls(response) + :return: SBTopic or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBTopic - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBTopic] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SBTopic] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'SBTopic') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBTopic") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -660,18 +941,18 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - 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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -679,67 +960,67 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBTopic', pipeline_response) + deserialized = self._deserialize("SBTopic", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}"} # type: ignore - + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}" + } @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, topic_name: str, **kwargs: Any ) -> None: """Deletes a topic from the specified namespace and resource group. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, topic_name=topic_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -750,60 +1031,60 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}"} # type: ignore - + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}" + } @distributed_trace_async async def get( - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, topic_name: str, **kwargs: Any ) -> _models.SBTopic: """Returns a description for the specified topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBTopic, or the result of cls(response) + :return: SBTopic or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBTopic - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBTopic] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[_models.SBTopic] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, topic_name=topic_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -811,12 +1092,13 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBTopic', pipeline_response) + deserialized = self._deserialize("SBTopic", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/models/__init__.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/models/__init__.py index 4f7e18adf2a1f..490670e8543a8 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/models/__init__.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/models/__init__.py @@ -70,110 +70,108 @@ from ._models_py3 import VirtualNetworkRule from ._models_py3 import VirtualNetworkRuleListResult - -from ._service_bus_management_client_enums import ( - AccessRights, - DefaultAction, - EncodingCaptureDescription, - EndPointProvisioningState, - EntityStatus, - FilterType, - IPAction, - KeyType, - MigrationConfigurationName, - NameSpaceType, - NetworkRuleIPAction, - PrivateLinkConnectionStatus, - ProvisioningStateDR, - RoleDisasterRecovery, - SkuName, - SkuTier, - UnavailableReason, -) +from ._service_bus_management_client_enums import AccessRights +from ._service_bus_management_client_enums import DefaultAction +from ._service_bus_management_client_enums import EncodingCaptureDescription +from ._service_bus_management_client_enums import EndPointProvisioningState +from ._service_bus_management_client_enums import EntityStatus +from ._service_bus_management_client_enums import FilterType +from ._service_bus_management_client_enums import IPAction +from ._service_bus_management_client_enums import KeyType +from ._service_bus_management_client_enums import MigrationConfigurationName +from ._service_bus_management_client_enums import NameSpaceType +from ._service_bus_management_client_enums import NetworkRuleIPAction +from ._service_bus_management_client_enums import PrivateLinkConnectionStatus +from ._service_bus_management_client_enums import ProvisioningStateDR +from ._service_bus_management_client_enums import RoleDisasterRecovery +from ._service_bus_management_client_enums import SkuName +from ._service_bus_management_client_enums import SkuTier +from ._service_bus_management_client_enums import UnavailableReason from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'AccessKeys', - 'Action', - 'ArmDisasterRecovery', - 'ArmDisasterRecoveryListResult', - 'CaptureDescription', - 'CheckNameAvailability', - 'CheckNameAvailabilityResult', - 'ConnectionState', - 'CorrelationFilter', - 'Destination', - 'Encryption', - 'ErrorAdditionalInfo', - 'ErrorResponse', - 'ErrorResponseError', - 'EventHubListResult', - 'Eventhub', - 'FailoverProperties', - 'Identity', - 'IpFilterRule', - 'IpFilterRuleListResult', - 'KeyVaultProperties', - 'MessageCountDetails', - 'MigrationConfigListResult', - 'MigrationConfigProperties', - 'NWRuleSetIpRules', - 'NWRuleSetVirtualNetworkRules', - 'NetworkRuleSet', - 'NetworkRuleSetListResult', - 'Operation', - 'OperationDisplay', - 'OperationListResult', - 'PremiumMessagingRegions', - 'PremiumMessagingRegionsListResult', - 'PremiumMessagingRegionsProperties', - 'PrivateEndpoint', - 'PrivateEndpointConnection', - 'PrivateEndpointConnectionListResult', - 'PrivateLinkResource', - 'PrivateLinkResourcesListResult', - 'RegenerateAccessKeyParameters', - 'Resource', - 'ResourceNamespacePatch', - 'Rule', - 'RuleListResult', - 'SBAuthorizationRule', - 'SBAuthorizationRuleListResult', - 'SBNamespace', - 'SBNamespaceListResult', - 'SBNamespaceMigrate', - 'SBNamespaceUpdateParameters', - 'SBQueue', - 'SBQueueListResult', - 'SBSku', - 'SBSubscription', - 'SBSubscriptionListResult', - 'SBTopic', - 'SBTopicListResult', - 'SqlFilter', - 'SqlRuleAction', - 'Subnet', - 'TrackedResource', - 'VirtualNetworkRule', - 'VirtualNetworkRuleListResult', - 'AccessRights', - 'DefaultAction', - 'EncodingCaptureDescription', - 'EndPointProvisioningState', - 'EntityStatus', - 'FilterType', - 'IPAction', - 'KeyType', - 'MigrationConfigurationName', - 'NameSpaceType', - 'NetworkRuleIPAction', - 'PrivateLinkConnectionStatus', - 'ProvisioningStateDR', - 'RoleDisasterRecovery', - 'SkuName', - 'SkuTier', - 'UnavailableReason', + "AccessKeys", + "Action", + "ArmDisasterRecovery", + "ArmDisasterRecoveryListResult", + "CaptureDescription", + "CheckNameAvailability", + "CheckNameAvailabilityResult", + "ConnectionState", + "CorrelationFilter", + "Destination", + "Encryption", + "ErrorAdditionalInfo", + "ErrorResponse", + "ErrorResponseError", + "EventHubListResult", + "Eventhub", + "FailoverProperties", + "Identity", + "IpFilterRule", + "IpFilterRuleListResult", + "KeyVaultProperties", + "MessageCountDetails", + "MigrationConfigListResult", + "MigrationConfigProperties", + "NWRuleSetIpRules", + "NWRuleSetVirtualNetworkRules", + "NetworkRuleSet", + "NetworkRuleSetListResult", + "Operation", + "OperationDisplay", + "OperationListResult", + "PremiumMessagingRegions", + "PremiumMessagingRegionsListResult", + "PremiumMessagingRegionsProperties", + "PrivateEndpoint", + "PrivateEndpointConnection", + "PrivateEndpointConnectionListResult", + "PrivateLinkResource", + "PrivateLinkResourcesListResult", + "RegenerateAccessKeyParameters", + "Resource", + "ResourceNamespacePatch", + "Rule", + "RuleListResult", + "SBAuthorizationRule", + "SBAuthorizationRuleListResult", + "SBNamespace", + "SBNamespaceListResult", + "SBNamespaceMigrate", + "SBNamespaceUpdateParameters", + "SBQueue", + "SBQueueListResult", + "SBSku", + "SBSubscription", + "SBSubscriptionListResult", + "SBTopic", + "SBTopicListResult", + "SqlFilter", + "SqlRuleAction", + "Subnet", + "TrackedResource", + "VirtualNetworkRule", + "VirtualNetworkRuleListResult", + "AccessRights", + "DefaultAction", + "EncodingCaptureDescription", + "EndPointProvisioningState", + "EntityStatus", + "FilterType", + "IPAction", + "KeyType", + "MigrationConfigurationName", + "NameSpaceType", + "NetworkRuleIPAction", + "PrivateLinkConnectionStatus", + "ProvisioningStateDR", + "RoleDisasterRecovery", + "SkuName", + "SkuTier", + "UnavailableReason", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/models/_models_py3.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/models/_models_py3.py index 13873fc557313..1c0ea662c6b7c 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/models/_models_py3.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_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,17 +8,22 @@ # -------------------------------------------------------------------------- import datetime +import sys from typing import Dict, List, Optional, TYPE_CHECKING, Union -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from ... import _serialization + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - import __init__ as _models + from .. import models as _models -class AccessKeys(msrest.serialization.Model): +class AccessKeys(_serialization.Model): """Namespace/ServiceBus Connection String. Variables are only populated by the server, and will be ignored when sending a request. @@ -45,32 +51,28 @@ class AccessKeys(msrest.serialization.Model): """ _validation = { - 'primary_connection_string': {'readonly': True}, - 'secondary_connection_string': {'readonly': True}, - 'alias_primary_connection_string': {'readonly': True}, - 'alias_secondary_connection_string': {'readonly': True}, - 'primary_key': {'readonly': True}, - 'secondary_key': {'readonly': True}, - 'key_name': {'readonly': True}, + "primary_connection_string": {"readonly": True}, + "secondary_connection_string": {"readonly": True}, + "alias_primary_connection_string": {"readonly": True}, + "alias_secondary_connection_string": {"readonly": True}, + "primary_key": {"readonly": True}, + "secondary_key": {"readonly": True}, + "key_name": {"readonly": True}, } _attribute_map = { - 'primary_connection_string': {'key': 'primaryConnectionString', 'type': 'str'}, - 'secondary_connection_string': {'key': 'secondaryConnectionString', 'type': 'str'}, - 'alias_primary_connection_string': {'key': 'aliasPrimaryConnectionString', 'type': 'str'}, - 'alias_secondary_connection_string': {'key': 'aliasSecondaryConnectionString', 'type': 'str'}, - 'primary_key': {'key': 'primaryKey', 'type': 'str'}, - 'secondary_key': {'key': 'secondaryKey', 'type': 'str'}, - 'key_name': {'key': 'keyName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - """ - """ - super(AccessKeys, self).__init__(**kwargs) + "primary_connection_string": {"key": "primaryConnectionString", "type": "str"}, + "secondary_connection_string": {"key": "secondaryConnectionString", "type": "str"}, + "alias_primary_connection_string": {"key": "aliasPrimaryConnectionString", "type": "str"}, + "alias_secondary_connection_string": {"key": "aliasSecondaryConnectionString", "type": "str"}, + "primary_key": {"key": "primaryKey", "type": "str"}, + "secondary_key": {"key": "secondaryKey", "type": "str"}, + "key_name": {"key": "keyName", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.primary_connection_string = None self.secondary_connection_string = None self.alias_primary_connection_string = None @@ -80,7 +82,7 @@ def __init__( self.key_name = None -class Action(msrest.serialization.Model): +class Action(_serialization.Model): """Represents the filter actions which are allowed for the transformation of a message that have been matched by a filter expression. :ivar sql_expression: SQL expression. e.g. MyProperty='ABC'. @@ -94,9 +96,9 @@ class Action(msrest.serialization.Model): """ _attribute_map = { - 'sql_expression': {'key': 'sqlExpression', 'type': 'str'}, - 'compatibility_level': {'key': 'compatibilityLevel', 'type': 'int'}, - 'requires_preprocessing': {'key': 'requiresPreprocessing', 'type': 'bool'}, + "sql_expression": {"key": "sqlExpression", "type": "str"}, + "compatibility_level": {"key": "compatibilityLevel", "type": "int"}, + "requires_preprocessing": {"key": "requiresPreprocessing", "type": "bool"}, } def __init__( @@ -104,7 +106,7 @@ def __init__( *, sql_expression: Optional[str] = None, compatibility_level: Optional[int] = None, - requires_preprocessing: Optional[bool] = True, + requires_preprocessing: bool = True, **kwargs ): """ @@ -117,13 +119,13 @@ def __init__( preprocessing. :paramtype requires_preprocessing: bool """ - super(Action, self).__init__(**kwargs) + super().__init__(**kwargs) self.sql_expression = sql_expression self.compatibility_level = compatibility_level self.requires_preprocessing = requires_preprocessing -class Resource(msrest.serialization.Model): +class Resource(_serialization.Model): """The Resource definition for other than namespace. Variables are only populated by the server, and will be ignored when sending a request. @@ -137,24 +139,20 @@ class Resource(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(Resource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -173,11 +171,11 @@ class ArmDisasterRecovery(Resource): :vartype type: str :ivar provisioning_state: Provisioning state of the Alias(Disaster Recovery configuration) - possible values 'Accepted' or 'Succeeded' or 'Failed'. Known values are: "Accepted", - "Succeeded", "Failed". + "Succeeded", and "Failed". :vartype provisioning_state: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.ProvisioningStateDR :ivar pending_replication_operations_count: Number of entities pending to be replicated. - :vartype pending_replication_operations_count: long + :vartype pending_replication_operations_count: int :ivar partner_namespace: ARM Id of the Primary/Secondary eventhub namespace name, which is part of GEO DR pairing. :vartype partner_namespace: str @@ -185,37 +183,31 @@ class ArmDisasterRecovery(Resource): pairing. :vartype alternate_name: str :ivar role: role of namespace in GEO DR - possible values 'Primary' or 'PrimaryNotReplicating' - or 'Secondary'. Known values are: "Primary", "PrimaryNotReplicating", "Secondary". + or 'Secondary'. Known values are: "Primary", "PrimaryNotReplicating", and "Secondary". :vartype role: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.RoleDisasterRecovery """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'pending_replication_operations_count': {'readonly': True}, - 'role': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "pending_replication_operations_count": {"readonly": True}, + "role": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'pending_replication_operations_count': {'key': 'properties.pendingReplicationOperationsCount', 'type': 'long'}, - 'partner_namespace': {'key': 'properties.partnerNamespace', 'type': 'str'}, - 'alternate_name': {'key': 'properties.alternateName', 'type': 'str'}, - 'role': {'key': 'properties.role', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "pending_replication_operations_count": {"key": "properties.pendingReplicationOperationsCount", "type": "int"}, + "partner_namespace": {"key": "properties.partnerNamespace", "type": "str"}, + "alternate_name": {"key": "properties.alternateName", "type": "str"}, + "role": {"key": "properties.role", "type": "str"}, } - def __init__( - self, - *, - partner_namespace: Optional[str] = None, - alternate_name: Optional[str] = None, - **kwargs - ): + def __init__(self, *, partner_namespace: Optional[str] = None, alternate_name: Optional[str] = None, **kwargs): """ :keyword partner_namespace: ARM Id of the Primary/Secondary eventhub namespace name, which is part of GEO DR pairing. @@ -224,7 +216,7 @@ def __init__( pairing. :paramtype alternate_name: str """ - super(ArmDisasterRecovery, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = None self.pending_replication_operations_count = None self.partner_namespace = partner_namespace @@ -232,7 +224,7 @@ def __init__( self.role = None -class ArmDisasterRecoveryListResult(msrest.serialization.Model): +class ArmDisasterRecoveryListResult(_serialization.Model): """The result of the List Alias(Disaster Recovery configuration) operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -245,36 +237,31 @@ class ArmDisasterRecoveryListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[ArmDisasterRecovery]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ArmDisasterRecovery]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["_models.ArmDisasterRecovery"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.ArmDisasterRecovery"]] = None, **kwargs): """ :keyword value: List of Alias(Disaster Recovery configurations). :paramtype value: list[~azure.mgmt.servicebus.v2018_01_01_preview.models.ArmDisasterRecovery] """ - super(ArmDisasterRecoveryListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class CaptureDescription(msrest.serialization.Model): +class CaptureDescription(_serialization.Model): """Properties to configure capture description for eventhub. :ivar enabled: A value that indicates whether capture description is enabled. :vartype enabled: bool :ivar encoding: Enumerates the possible values for the encoding format of capture description. - Known values are: "Avro", "AvroDeflate". + Known values are: "Avro" and "AvroDeflate". :vartype encoding: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.EncodingCaptureDescription :ivar interval_in_seconds: The time window allows you to set the frequency with which the @@ -289,16 +276,16 @@ class CaptureDescription(msrest.serialization.Model): """ _validation = { - 'interval_in_seconds': {'maximum': 900, 'minimum': 60}, - 'size_limit_in_bytes': {'maximum': 524288000, 'minimum': 10485760}, + "interval_in_seconds": {"maximum": 900, "minimum": 60}, + "size_limit_in_bytes": {"maximum": 524288000, "minimum": 10485760}, } _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'encoding': {'key': 'encoding', 'type': 'str'}, - 'interval_in_seconds': {'key': 'intervalInSeconds', 'type': 'int'}, - 'size_limit_in_bytes': {'key': 'sizeLimitInBytes', 'type': 'int'}, - 'destination': {'key': 'destination', 'type': 'Destination'}, + "enabled": {"key": "enabled", "type": "bool"}, + "encoding": {"key": "encoding", "type": "str"}, + "interval_in_seconds": {"key": "intervalInSeconds", "type": "int"}, + "size_limit_in_bytes": {"key": "sizeLimitInBytes", "type": "int"}, + "destination": {"key": "destination", "type": "Destination"}, } def __init__( @@ -315,7 +302,7 @@ def __init__( :keyword enabled: A value that indicates whether capture description is enabled. :paramtype enabled: bool :keyword encoding: Enumerates the possible values for the encoding format of capture - description. Known values are: "Avro", "AvroDeflate". + description. Known values are: "Avro" and "AvroDeflate". :paramtype encoding: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.EncodingCaptureDescription :keyword interval_in_seconds: The time window allows you to set the frequency with which the @@ -328,7 +315,7 @@ def __init__( Blob Names). :paramtype destination: ~azure.mgmt.servicebus.v2018_01_01_preview.models.Destination """ - super(CaptureDescription, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.encoding = encoding self.interval_in_seconds = interval_in_seconds @@ -336,42 +323,37 @@ def __init__( self.destination = destination -class CheckNameAvailability(msrest.serialization.Model): +class CheckNameAvailability(_serialization.Model): """Description of a Check Name availability request properties. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The Name to check the namespace name availability and The namespace name - can contain only letters, numbers, and hyphens. The namespace must start with a letter, and it - must end with a letter or number. + :ivar name: The Name to check the namespace name availability and The namespace name can + contain only letters, numbers, and hyphens. The namespace must start with a letter, and it must + end with a letter or number. 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 to check the namespace name availability and The namespace - name can contain only letters, numbers, and hyphens. The namespace must start with a letter, - and it must end with a letter or number. + :keyword name: The Name to check the namespace name availability and The namespace name can + contain only letters, numbers, and hyphens. The namespace must start with a letter, and it must + end with a letter or number. Required. :paramtype name: str """ - super(CheckNameAvailability, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class CheckNameAvailabilityResult(msrest.serialization.Model): +class CheckNameAvailabilityResult(_serialization.Model): """Description of a Check Name availability request properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -382,19 +364,19 @@ class CheckNameAvailabilityResult(msrest.serialization.Model): available; otherwise, false. :vartype name_available: bool :ivar reason: The reason for unavailability of a namespace. Known values are: "None", - "InvalidName", "SubscriptionIsDisabled", "NameInUse", "NameInLockdown", + "InvalidName", "SubscriptionIsDisabled", "NameInUse", "NameInLockdown", and "TooManyNamespaceInCurrentSubscription". :vartype reason: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.UnavailableReason """ _validation = { - 'message': {'readonly': True}, + "message": {"readonly": True}, } _attribute_map = { - 'message': {'key': 'message', 'type': 'str'}, - '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"}, } def __init__( @@ -409,21 +391,21 @@ def __init__( available; otherwise, false. :paramtype name_available: bool :keyword reason: The reason for unavailability of a namespace. Known values are: "None", - "InvalidName", "SubscriptionIsDisabled", "NameInUse", "NameInLockdown", + "InvalidName", "SubscriptionIsDisabled", "NameInUse", "NameInLockdown", and "TooManyNamespaceInCurrentSubscription". :paramtype reason: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.UnavailableReason """ - super(CheckNameAvailabilityResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.message = None self.name_available = name_available self.reason = reason -class ConnectionState(msrest.serialization.Model): +class ConnectionState(_serialization.Model): """ConnectionState information. :ivar status: Status of the connection. Known values are: "Pending", "Approved", "Rejected", - "Disconnected". + and "Disconnected". :vartype status: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.PrivateLinkConnectionStatus :ivar description: Description of the connection state. @@ -431,8 +413,8 @@ class ConnectionState(msrest.serialization.Model): """ _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, + "status": {"key": "status", "type": "str"}, + "description": {"key": "description", "type": "str"}, } def __init__( @@ -444,18 +426,18 @@ def __init__( ): """ :keyword status: Status of the connection. Known values are: "Pending", "Approved", "Rejected", - "Disconnected". + and "Disconnected". :paramtype status: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.PrivateLinkConnectionStatus :keyword description: Description of the connection state. :paramtype description: str """ - super(ConnectionState, self).__init__(**kwargs) + super().__init__(**kwargs) self.status = status self.description = description -class CorrelationFilter(msrest.serialization.Model): +class CorrelationFilter(_serialization.Model): """Represents the correlation filter expression. :ivar properties: dictionary object for custom filters. @@ -482,16 +464,16 @@ class CorrelationFilter(msrest.serialization.Model): """ _attribute_map = { - 'properties': {'key': 'properties', 'type': '{str}'}, - 'correlation_id': {'key': 'correlationId', 'type': 'str'}, - 'message_id': {'key': 'messageId', 'type': 'str'}, - 'to': {'key': 'to', 'type': 'str'}, - 'reply_to': {'key': 'replyTo', 'type': 'str'}, - 'label': {'key': 'label', 'type': 'str'}, - 'session_id': {'key': 'sessionId', 'type': 'str'}, - 'reply_to_session_id': {'key': 'replyToSessionId', 'type': 'str'}, - 'content_type': {'key': 'contentType', 'type': 'str'}, - 'requires_preprocessing': {'key': 'requiresPreprocessing', 'type': 'bool'}, + "properties": {"key": "properties", "type": "{str}"}, + "correlation_id": {"key": "correlationId", "type": "str"}, + "message_id": {"key": "messageId", "type": "str"}, + "to": {"key": "to", "type": "str"}, + "reply_to": {"key": "replyTo", "type": "str"}, + "label": {"key": "label", "type": "str"}, + "session_id": {"key": "sessionId", "type": "str"}, + "reply_to_session_id": {"key": "replyToSessionId", "type": "str"}, + "content_type": {"key": "contentType", "type": "str"}, + "requires_preprocessing": {"key": "requiresPreprocessing", "type": "bool"}, } def __init__( @@ -506,7 +488,7 @@ def __init__( session_id: Optional[str] = None, reply_to_session_id: Optional[str] = None, content_type: Optional[str] = None, - requires_preprocessing: Optional[bool] = True, + requires_preprocessing: bool = True, **kwargs ): """ @@ -532,7 +514,7 @@ def __init__( preprocessing. :paramtype requires_preprocessing: bool """ - super(CorrelationFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties self.correlation_id = correlation_id self.message_id = message_id @@ -545,7 +527,7 @@ def __init__( self.requires_preprocessing = requires_preprocessing -class Destination(msrest.serialization.Model): +class Destination(_serialization.Model): """Capture storage details for capture description. :ivar name: Name for capture destination. @@ -562,10 +544,10 @@ class Destination(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'storage_account_resource_id': {'key': 'properties.storageAccountResourceId', 'type': 'str'}, - 'blob_container': {'key': 'properties.blobContainer', 'type': 'str'}, - 'archive_name_format': {'key': 'properties.archiveNameFormat', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "storage_account_resource_id": {"key": "properties.storageAccountResourceId", "type": "str"}, + "blob_container": {"key": "properties.blobContainer", "type": "str"}, + "archive_name_format": {"key": "properties.archiveNameFormat", "type": "str"}, } def __init__( @@ -590,52 +572,50 @@ def __init__( the parameters (Namespace,EventHub .. etc) are mandatory irrespective of order. :paramtype archive_name_format: str """ - super(Destination, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.storage_account_resource_id = storage_account_resource_id self.blob_container = blob_container self.archive_name_format = archive_name_format -class Encryption(msrest.serialization.Model): +class Encryption(_serialization.Model): """Properties to configure Encryption. :ivar key_vault_properties: Properties of KeyVault. :vartype key_vault_properties: ~azure.mgmt.servicebus.v2018_01_01_preview.models.KeyVaultProperties - :ivar key_source: Enumerates the possible value of keySource for Encryption. The only - acceptable values to pass in are None and "Microsoft.KeyVault". The default value is + :ivar key_source: Enumerates the possible value of keySource for Encryption. Default value is "Microsoft.KeyVault". :vartype key_source: str """ _attribute_map = { - 'key_vault_properties': {'key': 'keyVaultProperties', 'type': 'KeyVaultProperties'}, - 'key_source': {'key': 'keySource', 'type': 'str'}, + "key_vault_properties": {"key": "keyVaultProperties", "type": "KeyVaultProperties"}, + "key_source": {"key": "keySource", "type": "str"}, } def __init__( self, *, key_vault_properties: Optional["_models.KeyVaultProperties"] = None, - key_source: Optional[str] = "Microsoft.KeyVault", + key_source: Literal["Microsoft.KeyVault"] = "Microsoft.KeyVault", **kwargs ): """ :keyword key_vault_properties: Properties of KeyVault. :paramtype key_vault_properties: ~azure.mgmt.servicebus.v2018_01_01_preview.models.KeyVaultProperties - :keyword key_source: Enumerates the possible value of keySource for Encryption. The only - acceptable values to pass in are None and "Microsoft.KeyVault". The default value is - "Microsoft.KeyVault". + :keyword key_source: Enumerates the possible value of keySource for Encryption. Default value + is "Microsoft.KeyVault". :paramtype key_source: str """ - super(Encryption, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_vault_properties = key_vault_properties self.key_source = key_source -class ErrorAdditionalInfo(msrest.serialization.Model): +class ErrorAdditionalInfo(_serialization.Model): """The resource management error additional info. Variables are only populated by the server, and will be ignored when sending a request. @@ -643,31 +623,27 @@ class ErrorAdditionalInfo(msrest.serialization.Model): :ivar type: The additional info type. :vartype type: str :ivar info: The additional info. - :vartype info: any + :vartype info: JSON """ _validation = { - 'type': {'readonly': True}, - 'info': {'readonly': True}, + "type": {"readonly": True}, + "info": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'info': {'key': 'info', 'type': 'object'}, + "type": {"key": "type", "type": "str"}, + "info": {"key": "info", "type": "object"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorAdditionalInfo, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.type = None self.info = None -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_serialization.Model): """The resource management error response. :ivar error: The error object. @@ -675,24 +651,19 @@ class ErrorResponse(msrest.serialization.Model): """ _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorResponseError'}, + "error": {"key": "error", "type": "ErrorResponseError"}, } - def __init__( - self, - *, - error: Optional["_models.ErrorResponseError"] = None, - **kwargs - ): + def __init__(self, *, error: Optional["_models.ErrorResponseError"] = None, **kwargs): """ :keyword error: The error object. :paramtype error: ~azure.mgmt.servicebus.v2018_01_01_preview.models.ErrorResponseError """ - super(ErrorResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.error = error -class ErrorResponseError(msrest.serialization.Model): +class ErrorResponseError(_serialization.Model): """The error object. Variables are only populated by the server, and will be ignored when sending a request. @@ -711,28 +682,24 @@ class ErrorResponseError(msrest.serialization.Model): """ _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - 'details': {'readonly': True}, - 'additional_info': {'readonly': True}, + "code": {"readonly": True}, + "message": {"readonly": True}, + "target": {"readonly": True}, + "details": {"readonly": True}, + "additional_info": {"readonly": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ErrorResponse]'}, - 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[ErrorResponse]"}, + "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorResponseError, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.code = None self.message = None self.target = None @@ -759,13 +726,13 @@ class Eventhub(Resource): :vartype updated_at: ~datetime.datetime :ivar message_retention_in_days: Number of days to retain the events for this Event Hub, value should be 1 to 7 days. - :vartype message_retention_in_days: long + :vartype message_retention_in_days: int :ivar partition_count: Number of partitions created for the Event Hub, allowed values are from 1 to 32 partitions. - :vartype partition_count: long + :vartype partition_count: int :ivar status: Enumerates the possible values for the status of a Event Hub. Known values are: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", "Creating", "Deleting", - "Renaming", "Unknown". + "Renaming", and "Unknown". :vartype status: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.EntityStatus :ivar capture_description: Properties of capture description. :vartype capture_description: @@ -773,27 +740,27 @@ class Eventhub(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'partition_ids': {'readonly': True}, - 'created_at': {'readonly': True}, - 'updated_at': {'readonly': True}, - 'message_retention_in_days': {'maximum': 7, 'minimum': 1}, - 'partition_count': {'maximum': 32, 'minimum': 1}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "partition_ids": {"readonly": True}, + "created_at": {"readonly": True}, + "updated_at": {"readonly": True}, + "message_retention_in_days": {"maximum": 7, "minimum": 1}, + "partition_count": {"maximum": 32, "minimum": 1}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'partition_ids': {'key': 'properties.partitionIds', 'type': '[str]'}, - 'created_at': {'key': 'properties.createdAt', 'type': 'iso-8601'}, - 'updated_at': {'key': 'properties.updatedAt', 'type': 'iso-8601'}, - 'message_retention_in_days': {'key': 'properties.messageRetentionInDays', 'type': 'long'}, - 'partition_count': {'key': 'properties.partitionCount', 'type': 'long'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'capture_description': {'key': 'properties.captureDescription', 'type': 'CaptureDescription'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "partition_ids": {"key": "properties.partitionIds", "type": "[str]"}, + "created_at": {"key": "properties.createdAt", "type": "iso-8601"}, + "updated_at": {"key": "properties.updatedAt", "type": "iso-8601"}, + "message_retention_in_days": {"key": "properties.messageRetentionInDays", "type": "int"}, + "partition_count": {"key": "properties.partitionCount", "type": "int"}, + "status": {"key": "properties.status", "type": "str"}, + "capture_description": {"key": "properties.captureDescription", "type": "CaptureDescription"}, } def __init__( @@ -808,19 +775,19 @@ def __init__( """ :keyword message_retention_in_days: Number of days to retain the events for this Event Hub, value should be 1 to 7 days. - :paramtype message_retention_in_days: long + :paramtype message_retention_in_days: int :keyword partition_count: Number of partitions created for the Event Hub, allowed values are from 1 to 32 partitions. - :paramtype partition_count: long + :paramtype partition_count: int :keyword status: Enumerates the possible values for the status of a Event Hub. Known values are: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", "Creating", - "Deleting", "Renaming", "Unknown". + "Deleting", "Renaming", and "Unknown". :paramtype status: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.EntityStatus :keyword capture_description: Properties of capture description. :paramtype capture_description: ~azure.mgmt.servicebus.v2018_01_01_preview.models.CaptureDescription """ - super(Eventhub, self).__init__(**kwargs) + super().__init__(**kwargs) self.partition_ids = None self.created_at = None self.updated_at = None @@ -830,7 +797,7 @@ def __init__( self.capture_description = capture_description -class EventHubListResult(msrest.serialization.Model): +class EventHubListResult(_serialization.Model): """The result of the List EventHubs operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -843,30 +810,25 @@ class EventHubListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Eventhub]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Eventhub]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["_models.Eventhub"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Eventhub"]] = None, **kwargs): """ :keyword value: Result of the List EventHubs operation. :paramtype value: list[~azure.mgmt.servicebus.v2018_01_01_preview.models.Eventhub] """ - super(EventHubListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class FailoverProperties(msrest.serialization.Model): +class FailoverProperties(_serialization.Model): """Safe failover is to indicate the service should wait for pending replication to finish before switching to the secondary. :ivar is_safe_failover: Safe failover is to indicate the service should wait for pending @@ -875,25 +837,20 @@ class FailoverProperties(msrest.serialization.Model): """ _attribute_map = { - 'is_safe_failover': {'key': 'properties.IsSafeFailover', 'type': 'bool'}, + "is_safe_failover": {"key": "properties.IsSafeFailover", "type": "bool"}, } - def __init__( - self, - *, - is_safe_failover: Optional[bool] = None, - **kwargs - ): + def __init__(self, *, is_safe_failover: Optional[bool] = None, **kwargs): """ :keyword is_safe_failover: Safe failover is to indicate the service should wait for pending replication to finish before switching to the secondary. :paramtype is_safe_failover: bool """ - super(FailoverProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.is_safe_failover = is_safe_failover -class Identity(msrest.serialization.Model): +class Identity(_serialization.Model): """Properties to configure Identity for Bring your Own Keys. :ivar principal_id: ObjectId from the KeyVault. @@ -901,15 +858,14 @@ class Identity(msrest.serialization.Model): :ivar tenant_id: TenantId from the KeyVault. :vartype tenant_id: str :ivar type: Enumerates the possible value Identity type, which currently supports only - 'SystemAssigned'. The only acceptable values to pass in are None and "SystemAssigned". The - default value is "SystemAssigned". + 'SystemAssigned'. Default value is "SystemAssigned". :vartype type: str """ _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, } def __init__( @@ -917,7 +873,7 @@ def __init__( *, principal_id: Optional[str] = None, tenant_id: Optional[str] = None, - type: Optional[str] = "SystemAssigned", + type: Literal["SystemAssigned"] = "SystemAssigned", **kwargs ): """ @@ -926,11 +882,10 @@ def __init__( :keyword tenant_id: TenantId from the KeyVault. :paramtype tenant_id: str :keyword type: Enumerates the possible value Identity type, which currently supports only - 'SystemAssigned'. The only acceptable values to pass in are None and "SystemAssigned". The - default value is "SystemAssigned". + 'SystemAssigned'. Default value is "SystemAssigned". :paramtype type: str """ - super(Identity, self).__init__(**kwargs) + super().__init__(**kwargs) self.principal_id = principal_id self.tenant_id = tenant_id self.type = type @@ -949,25 +904,25 @@ class IpFilterRule(Resource): :vartype type: str :ivar ip_mask: IP Mask. :vartype ip_mask: str - :ivar action: The IP Filter Action. Known values are: "Accept", "Reject". + :ivar action: The IP Filter Action. Known values are: "Accept" and "Reject". :vartype action: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.IPAction :ivar filter_name: IP Filter name. :vartype filter_name: str """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'ip_mask': {'key': 'properties.ipMask', 'type': 'str'}, - 'action': {'key': 'properties.action', 'type': 'str'}, - 'filter_name': {'key': 'properties.filterName', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "ip_mask": {"key": "properties.ipMask", "type": "str"}, + "action": {"key": "properties.action", "type": "str"}, + "filter_name": {"key": "properties.filterName", "type": "str"}, } def __init__( @@ -981,18 +936,18 @@ def __init__( """ :keyword ip_mask: IP Mask. :paramtype ip_mask: str - :keyword action: The IP Filter Action. Known values are: "Accept", "Reject". + :keyword action: The IP Filter Action. Known values are: "Accept" and "Reject". :paramtype action: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.IPAction :keyword filter_name: IP Filter name. :paramtype filter_name: str """ - super(IpFilterRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.ip_mask = ip_mask self.action = action self.filter_name = filter_name -class IpFilterRuleListResult(msrest.serialization.Model): +class IpFilterRuleListResult(_serialization.Model): """The response from the List namespace operation. :ivar value: Result of the List IpFilter Rules operation. @@ -1003,16 +958,12 @@ class IpFilterRuleListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[IpFilterRule]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[IpFilterRule]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["_models.IpFilterRule"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.IpFilterRule"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Result of the List IpFilter Rules operation. @@ -1021,12 +972,12 @@ def __init__( list of IpFilter Rules. :paramtype next_link: str """ - super(IpFilterRuleListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class KeyVaultProperties(msrest.serialization.Model): +class KeyVaultProperties(_serialization.Model): """Properties to configure keyVault Properties. :ivar key_name: Name of the Key from KeyVault. @@ -1036,69 +987,59 @@ class KeyVaultProperties(msrest.serialization.Model): """ _attribute_map = { - 'key_name': {'key': 'keyName', 'type': 'str'}, - 'key_vault_uri': {'key': 'keyVaultUri', 'type': 'str'}, + "key_name": {"key": "keyName", "type": "str"}, + "key_vault_uri": {"key": "keyVaultUri", "type": "str"}, } - def __init__( - self, - *, - key_name: Optional[str] = None, - key_vault_uri: Optional[str] = None, - **kwargs - ): + def __init__(self, *, key_name: Optional[str] = None, key_vault_uri: Optional[str] = None, **kwargs): """ :keyword key_name: Name of the Key from KeyVault. :paramtype key_name: str :keyword key_vault_uri: Uri of KeyVault. :paramtype key_vault_uri: str """ - super(KeyVaultProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_name = key_name self.key_vault_uri = key_vault_uri -class MessageCountDetails(msrest.serialization.Model): +class MessageCountDetails(_serialization.Model): """Message Count Details. Variables are only populated by the server, and will be ignored when sending a request. :ivar active_message_count: Number of active messages in the queue, topic, or subscription. - :vartype active_message_count: long + :vartype active_message_count: int :ivar dead_letter_message_count: Number of messages that are dead lettered. - :vartype dead_letter_message_count: long + :vartype dead_letter_message_count: int :ivar scheduled_message_count: Number of scheduled messages. - :vartype scheduled_message_count: long + :vartype scheduled_message_count: int :ivar transfer_message_count: Number of messages transferred to another queue, topic, or subscription. - :vartype transfer_message_count: long + :vartype transfer_message_count: int :ivar transfer_dead_letter_message_count: Number of messages transferred into dead letters. - :vartype transfer_dead_letter_message_count: long + :vartype transfer_dead_letter_message_count: int """ _validation = { - 'active_message_count': {'readonly': True}, - 'dead_letter_message_count': {'readonly': True}, - 'scheduled_message_count': {'readonly': True}, - 'transfer_message_count': {'readonly': True}, - 'transfer_dead_letter_message_count': {'readonly': True}, + "active_message_count": {"readonly": True}, + "dead_letter_message_count": {"readonly": True}, + "scheduled_message_count": {"readonly": True}, + "transfer_message_count": {"readonly": True}, + "transfer_dead_letter_message_count": {"readonly": True}, } _attribute_map = { - 'active_message_count': {'key': 'activeMessageCount', 'type': 'long'}, - 'dead_letter_message_count': {'key': 'deadLetterMessageCount', 'type': 'long'}, - 'scheduled_message_count': {'key': 'scheduledMessageCount', 'type': 'long'}, - 'transfer_message_count': {'key': 'transferMessageCount', 'type': 'long'}, - 'transfer_dead_letter_message_count': {'key': 'transferDeadLetterMessageCount', 'type': 'long'}, + "active_message_count": {"key": "activeMessageCount", "type": "int"}, + "dead_letter_message_count": {"key": "deadLetterMessageCount", "type": "int"}, + "scheduled_message_count": {"key": "scheduledMessageCount", "type": "int"}, + "transfer_message_count": {"key": "transferMessageCount", "type": "int"}, + "transfer_dead_letter_message_count": {"key": "transferDeadLetterMessageCount", "type": "int"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(MessageCountDetails, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.active_message_count = None self.dead_letter_message_count = None self.scheduled_message_count = None @@ -1106,7 +1047,7 @@ def __init__( self.transfer_dead_letter_message_count = None -class MigrationConfigListResult(msrest.serialization.Model): +class MigrationConfigListResult(_serialization.Model): """The result of the List migrationConfigurations operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -1120,26 +1061,21 @@ class MigrationConfigListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[MigrationConfigProperties]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[MigrationConfigProperties]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["_models.MigrationConfigProperties"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.MigrationConfigProperties"]] = None, **kwargs): """ :keyword value: List of Migration Configs. :paramtype value: list[~azure.mgmt.servicebus.v2018_01_01_preview.models.MigrationConfigProperties] """ - super(MigrationConfigListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None @@ -1158,7 +1094,7 @@ class MigrationConfigProperties(Resource): :ivar provisioning_state: Provisioning state of Migration Configuration. :vartype provisioning_state: str :ivar pending_replication_operations_count: Number of entities pending to be replicated. - :vartype pending_replication_operations_count: long + :vartype pending_replication_operations_count: int :ivar target_namespace: Existing premium Namespace ARM Id name which has no entities, will be used for migration. :vartype target_namespace: str @@ -1170,32 +1106,26 @@ class MigrationConfigProperties(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'pending_replication_operations_count': {'readonly': True}, - 'migration_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "pending_replication_operations_count": {"readonly": True}, + "migration_state": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'pending_replication_operations_count': {'key': 'properties.pendingReplicationOperationsCount', 'type': 'long'}, - 'target_namespace': {'key': 'properties.targetNamespace', 'type': 'str'}, - 'post_migration_name': {'key': 'properties.postMigrationName', 'type': 'str'}, - 'migration_state': {'key': 'properties.migrationState', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "pending_replication_operations_count": {"key": "properties.pendingReplicationOperationsCount", "type": "int"}, + "target_namespace": {"key": "properties.targetNamespace", "type": "str"}, + "post_migration_name": {"key": "properties.postMigrationName", "type": "str"}, + "migration_state": {"key": "properties.migrationState", "type": "str"}, } - def __init__( - self, - *, - target_namespace: Optional[str] = None, - post_migration_name: Optional[str] = None, - **kwargs - ): + def __init__(self, *, target_namespace: Optional[str] = None, post_migration_name: Optional[str] = None, **kwargs): """ :keyword target_namespace: Existing premium Namespace ARM Id name which has no entities, will be used for migration. @@ -1203,7 +1133,7 @@ def __init__( :keyword post_migration_name: Name to access Standard Namespace after migration. :paramtype post_migration_name: str """ - super(MigrationConfigProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = None self.pending_replication_operations_count = None self.target_namespace = target_namespace @@ -1222,7 +1152,8 @@ class NetworkRuleSet(Resource): :vartype name: str :ivar type: Resource type. :vartype type: str - :ivar default_action: Default Action for Network Rule Set. Known values are: "Allow", "Deny". + :ivar default_action: Default Action for Network Rule Set. Known values are: "Allow" and + "Deny". :vartype default_action: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.DefaultAction :ivar virtual_network_rules: List VirtualNetwork Rules. :vartype virtual_network_rules: @@ -1232,18 +1163,18 @@ class NetworkRuleSet(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'default_action': {'key': 'properties.defaultAction', 'type': 'str'}, - 'virtual_network_rules': {'key': 'properties.virtualNetworkRules', 'type': '[NWRuleSetVirtualNetworkRules]'}, - 'ip_rules': {'key': 'properties.ipRules', 'type': '[NWRuleSetIpRules]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "default_action": {"key": "properties.defaultAction", "type": "str"}, + "virtual_network_rules": {"key": "properties.virtualNetworkRules", "type": "[NWRuleSetVirtualNetworkRules]"}, + "ip_rules": {"key": "properties.ipRules", "type": "[NWRuleSetIpRules]"}, } def __init__( @@ -1255,7 +1186,7 @@ def __init__( **kwargs ): """ - :keyword default_action: Default Action for Network Rule Set. Known values are: "Allow", + :keyword default_action: Default Action for Network Rule Set. Known values are: "Allow" and "Deny". :paramtype default_action: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.DefaultAction @@ -1265,13 +1196,13 @@ def __init__( :keyword ip_rules: List of IpRules. :paramtype ip_rules: list[~azure.mgmt.servicebus.v2018_01_01_preview.models.NWRuleSetIpRules] """ - super(NetworkRuleSet, self).__init__(**kwargs) + super().__init__(**kwargs) self.default_action = default_action self.virtual_network_rules = virtual_network_rules self.ip_rules = ip_rules -class NetworkRuleSetListResult(msrest.serialization.Model): +class NetworkRuleSetListResult(_serialization.Model): """The response of the List NetworkRuleSet operation. :ivar value: Result of the List NetworkRuleSet operation. @@ -1282,16 +1213,12 @@ class NetworkRuleSetListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[NetworkRuleSet]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[NetworkRuleSet]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["_models.NetworkRuleSet"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.NetworkRuleSet"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Result of the List NetworkRuleSet operation. @@ -1300,44 +1227,40 @@ def __init__( list of NetworkRuleSet. :paramtype next_link: str """ - super(NetworkRuleSetListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class NWRuleSetIpRules(msrest.serialization.Model): +class NWRuleSetIpRules(_serialization.Model): """Description of NetWorkRuleSet - IpRules resource. :ivar ip_mask: IP Mask. :vartype ip_mask: str - :ivar action: The IP Filter Action. Known values are: "Allow". Default value: "Allow". + :ivar action: The IP Filter Action. "Allow" :vartype action: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.NetworkRuleIPAction """ _attribute_map = { - 'ip_mask': {'key': 'ipMask', 'type': 'str'}, - 'action': {'key': 'action', 'type': 'str'}, + "ip_mask": {"key": "ipMask", "type": "str"}, + "action": {"key": "action", "type": "str"}, } def __init__( - self, - *, - ip_mask: Optional[str] = None, - action: Optional[Union[str, "_models.NetworkRuleIPAction"]] = "Allow", - **kwargs + self, *, ip_mask: Optional[str] = None, action: Union[str, "_models.NetworkRuleIPAction"] = "Allow", **kwargs ): """ :keyword ip_mask: IP Mask. :paramtype ip_mask: str - :keyword action: The IP Filter Action. Known values are: "Allow". Default value: "Allow". + :keyword action: The IP Filter Action. "Allow" :paramtype action: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.NetworkRuleIPAction """ - super(NWRuleSetIpRules, self).__init__(**kwargs) + super().__init__(**kwargs) self.ip_mask = ip_mask self.action = action -class NWRuleSetVirtualNetworkRules(msrest.serialization.Model): +class NWRuleSetVirtualNetworkRules(_serialization.Model): """Description of VirtualNetworkRules - NetworkRules resource. :ivar subnet: Subnet properties. @@ -1348,8 +1271,8 @@ class NWRuleSetVirtualNetworkRules(msrest.serialization.Model): """ _attribute_map = { - 'subnet': {'key': 'subnet', 'type': 'Subnet'}, - 'ignore_missing_vnet_service_endpoint': {'key': 'ignoreMissingVnetServiceEndpoint', 'type': 'bool'}, + "subnet": {"key": "subnet", "type": "Subnet"}, + "ignore_missing_vnet_service_endpoint": {"key": "ignoreMissingVnetServiceEndpoint", "type": "bool"}, } def __init__( @@ -1366,12 +1289,12 @@ def __init__( VNet Service Endpoint. :paramtype ignore_missing_vnet_service_endpoint: bool """ - super(NWRuleSetVirtualNetworkRules, self).__init__(**kwargs) + super().__init__(**kwargs) self.subnet = subnet self.ignore_missing_vnet_service_endpoint = ignore_missing_vnet_service_endpoint -class Operation(msrest.serialization.Model): +class Operation(_serialization.Model): """A ServiceBus REST API operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -1383,30 +1306,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["_models.OperationDisplay"] = None, - **kwargs - ): + def __init__(self, *, display: Optional["_models.OperationDisplay"] = None, **kwargs): """ :keyword display: The object that represents the operation. :paramtype display: ~azure.mgmt.servicebus.v2018_01_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. @@ -1420,30 +1338,26 @@ 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 OperationListResult(msrest.serialization.Model): +class OperationListResult(_serialization.Model): """Result of the request to list ServiceBus 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. @@ -1456,22 +1370,18 @@ 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 @@ -1489,38 +1399,32 @@ class ResourceNamespacePatch(Resource): :vartype type: str :ivar location: Resource location. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"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}'}, + "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: Optional[str] = None, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, **kwargs): """ :keyword location: Resource location. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] """ - super(ResourceNamespacePatch, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.tags = tags @@ -1538,7 +1442,7 @@ class PremiumMessagingRegions(ResourceNamespacePatch): :vartype type: str :ivar location: Resource location. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar properties: :vartype properties: @@ -1546,18 +1450,18 @@ class PremiumMessagingRegions(ResourceNamespacePatch): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"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}'}, - 'properties': {'key': 'properties', 'type': 'PremiumMessagingRegionsProperties'}, + "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}"}, + "properties": {"key": "properties", "type": "PremiumMessagingRegionsProperties"}, } def __init__( @@ -1571,17 +1475,17 @@ def __init__( """ :keyword location: Resource location. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword properties: :paramtype properties: ~azure.mgmt.servicebus.v2018_01_01_preview.models.PremiumMessagingRegionsProperties """ - super(PremiumMessagingRegions, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.properties = properties -class PremiumMessagingRegionsListResult(msrest.serialization.Model): +class PremiumMessagingRegionsListResult(_serialization.Model): """The response of the List PremiumMessagingRegions operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -1594,31 +1498,26 @@ class PremiumMessagingRegionsListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[PremiumMessagingRegions]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[PremiumMessagingRegions]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["_models.PremiumMessagingRegions"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.PremiumMessagingRegions"]] = None, **kwargs): """ :keyword value: Result of the List PremiumMessagingRegions type. :paramtype value: list[~azure.mgmt.servicebus.v2018_01_01_preview.models.PremiumMessagingRegions] """ - super(PremiumMessagingRegionsListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class PremiumMessagingRegionsProperties(msrest.serialization.Model): +class PremiumMessagingRegionsProperties(_serialization.Model): """PremiumMessagingRegionsProperties. Variables are only populated by the server, and will be ignored when sending a request. @@ -1630,27 +1529,23 @@ class PremiumMessagingRegionsProperties(msrest.serialization.Model): """ _validation = { - 'code': {'readonly': True}, - 'full_name': {'readonly': True}, + "code": {"readonly": True}, + "full_name": {"readonly": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'full_name': {'key': 'fullName', 'type': 'str'}, + "code": {"key": "code", "type": "str"}, + "full_name": {"key": "fullName", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(PremiumMessagingRegionsProperties, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.code = None self.full_name = None -class PrivateEndpoint(msrest.serialization.Model): +class PrivateEndpoint(_serialization.Model): """PrivateEndpoint information. :ivar id: The ARM identifier for Private Endpoint. @@ -1658,20 +1553,15 @@ class PrivateEndpoint(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - *, - id: Optional[str] = None, - **kwargs - ): + def __init__(self, *, id: Optional[str] = None, **kwargs): # pylint: disable=redefined-builtin """ :keyword id: The ARM identifier for Private Endpoint. :paramtype id: str """ - super(PrivateEndpoint, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id @@ -1692,24 +1582,27 @@ class PrivateEndpointConnection(Resource): :vartype private_link_service_connection_state: ~azure.mgmt.servicebus.v2018_01_01_preview.models.ConnectionState :ivar provisioning_state: Provisioning state of the Private Endpoint Connection. Known values - are: "Creating", "Updating", "Deleting", "Succeeded", "Canceled", "Failed". + are: "Creating", "Updating", "Deleting", "Succeeded", "Canceled", and "Failed". :vartype provisioning_state: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.EndPointProvisioningState """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'private_endpoint': {'key': 'properties.privateEndpoint', 'type': 'PrivateEndpoint'}, - 'private_link_service_connection_state': {'key': 'properties.privateLinkServiceConnectionState', 'type': 'ConnectionState'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "private_endpoint": {"key": "properties.privateEndpoint", "type": "PrivateEndpoint"}, + "private_link_service_connection_state": { + "key": "properties.privateLinkServiceConnectionState", + "type": "ConnectionState", + }, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, } def __init__( @@ -1727,17 +1620,17 @@ def __init__( :paramtype private_link_service_connection_state: ~azure.mgmt.servicebus.v2018_01_01_preview.models.ConnectionState :keyword provisioning_state: Provisioning state of the Private Endpoint Connection. Known - values are: "Creating", "Updating", "Deleting", "Succeeded", "Canceled", "Failed". + values are: "Creating", "Updating", "Deleting", "Succeeded", "Canceled", and "Failed". :paramtype provisioning_state: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.EndPointProvisioningState """ - super(PrivateEndpointConnection, self).__init__(**kwargs) + super().__init__(**kwargs) self.private_endpoint = private_endpoint self.private_link_service_connection_state = private_link_service_connection_state self.provisioning_state = provisioning_state -class PrivateEndpointConnectionListResult(msrest.serialization.Model): +class PrivateEndpointConnectionListResult(_serialization.Model): """Result of the list of all private endpoint connections operation. :ivar value: A collection of private endpoint connection resources. @@ -1748,8 +1641,8 @@ class PrivateEndpointConnectionListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PrivateEndpointConnection]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[PrivateEndpointConnection]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( @@ -1766,12 +1659,12 @@ def __init__( :keyword next_link: A link for the next page of private endpoint connection resources. :paramtype next_link: str """ - super(PrivateEndpointConnectionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class PrivateLinkResource(msrest.serialization.Model): +class PrivateLinkResource(_serialization.Model): """Information of the private link resource. :ivar id: Fully qualified identifier of the resource. @@ -1789,18 +1682,18 @@ class PrivateLinkResource(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'group_id': {'key': 'properties.groupId', 'type': 'str'}, - 'required_members': {'key': 'properties.requiredMembers', 'type': '[str]'}, - 'required_zone_names': {'key': 'properties.requiredZoneNames', 'type': '[str]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "group_id": {"key": "properties.groupId", "type": "str"}, + "required_members": {"key": "properties.requiredMembers", "type": "[str]"}, + "required_zone_names": {"key": "properties.requiredZoneNames", "type": "[str]"}, } def __init__( self, *, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin name: Optional[str] = None, type: Optional[str] = None, group_id: Optional[str] = None, @@ -1822,7 +1715,7 @@ def __init__( :keyword required_zone_names: Required Zone Names. :paramtype required_zone_names: list[str] """ - super(PrivateLinkResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.name = name self.type = type @@ -1831,7 +1724,7 @@ def __init__( self.required_zone_names = required_zone_names -class PrivateLinkResourcesListResult(msrest.serialization.Model): +class PrivateLinkResourcesListResult(_serialization.Model): """Result of the List private link resources operation. :ivar value: A collection of private link resources. @@ -1841,16 +1734,12 @@ class PrivateLinkResourcesListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PrivateLinkResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[PrivateLinkResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["_models.PrivateLinkResource"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.PrivateLinkResource"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: A collection of private link resources. @@ -1858,17 +1747,17 @@ def __init__( :keyword next_link: A link for the next page of private link resources. :paramtype next_link: str """ - super(PrivateLinkResourcesListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class RegenerateAccessKeyParameters(msrest.serialization.Model): +class RegenerateAccessKeyParameters(_serialization.Model): """Parameters supplied to the Regenerate Authorization Rule operation, specifies which key needs to be reset. All required parameters must be populated in order to send to Azure. - :ivar key_type: Required. The access key to regenerate. Known values are: "PrimaryKey", + :ivar key_type: The access key to regenerate. Required. Known values are: "PrimaryKey" and "SecondaryKey". :vartype key_type: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.KeyType :ivar key: Optional, if the key value provided, is reset for KeyType value or autogenerate Key @@ -1877,30 +1766,24 @@ class RegenerateAccessKeyParameters(msrest.serialization.Model): """ _validation = { - 'key_type': {'required': True}, + "key_type": {"required": True}, } _attribute_map = { - 'key_type': {'key': 'keyType', 'type': 'str'}, - 'key': {'key': 'key', 'type': 'str'}, + "key_type": {"key": "keyType", "type": "str"}, + "key": {"key": "key", "type": "str"}, } - def __init__( - self, - *, - key_type: Union[str, "_models.KeyType"], - key: Optional[str] = None, - **kwargs - ): + def __init__(self, *, key_type: Union[str, "_models.KeyType"], key: Optional[str] = None, **kwargs): """ - :keyword key_type: Required. The access key to regenerate. Known values are: "PrimaryKey", + :keyword key_type: The access key to regenerate. Required. Known values are: "PrimaryKey" and "SecondaryKey". :paramtype key_type: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.KeyType :keyword key: Optional, if the key value provided, is reset for KeyType value or autogenerate Key value set for keyType. :paramtype key: str """ - super(RegenerateAccessKeyParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_type = key_type self.key = key @@ -1920,7 +1803,7 @@ class Rule(Resource): message that have been matched by a filter expression. :vartype action: ~azure.mgmt.servicebus.v2018_01_01_preview.models.Action :ivar filter_type: Filter type that is evaluated against a BrokeredMessage. Known values are: - "SqlFilter", "CorrelationFilter". + "SqlFilter" and "CorrelationFilter". :vartype filter_type: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.FilterType :ivar sql_filter: Properties of sqlFilter. :vartype sql_filter: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SqlFilter @@ -1930,19 +1813,19 @@ class Rule(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'action': {'key': 'properties.action', 'type': 'Action'}, - 'filter_type': {'key': 'properties.filterType', 'type': 'str'}, - 'sql_filter': {'key': 'properties.sqlFilter', 'type': 'SqlFilter'}, - 'correlation_filter': {'key': 'properties.correlationFilter', 'type': 'CorrelationFilter'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "action": {"key": "properties.action", "type": "Action"}, + "filter_type": {"key": "properties.filterType", "type": "str"}, + "sql_filter": {"key": "properties.sqlFilter", "type": "SqlFilter"}, + "correlation_filter": {"key": "properties.correlationFilter", "type": "CorrelationFilter"}, } def __init__( @@ -1959,7 +1842,7 @@ def __init__( message that have been matched by a filter expression. :paramtype action: ~azure.mgmt.servicebus.v2018_01_01_preview.models.Action :keyword filter_type: Filter type that is evaluated against a BrokeredMessage. Known values - are: "SqlFilter", "CorrelationFilter". + are: "SqlFilter" and "CorrelationFilter". :paramtype filter_type: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.FilterType :keyword sql_filter: Properties of sqlFilter. :paramtype sql_filter: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SqlFilter @@ -1967,14 +1850,14 @@ def __init__( :paramtype correlation_filter: ~azure.mgmt.servicebus.v2018_01_01_preview.models.CorrelationFilter """ - super(Rule, self).__init__(**kwargs) + super().__init__(**kwargs) self.action = action self.filter_type = filter_type self.sql_filter = sql_filter self.correlation_filter = correlation_filter -class RuleListResult(msrest.serialization.Model): +class RuleListResult(_serialization.Model): """The response of the List rule operation. :ivar value: Result of the List Rules operation. @@ -1985,17 +1868,11 @@ class RuleListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Rule]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Rule]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["_models.Rule"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Rule"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: Result of the List Rules operation. :paramtype value: list[~azure.mgmt.servicebus.v2018_01_01_preview.models.Rule] @@ -2003,7 +1880,7 @@ def __init__( list of rules. :paramtype next_link: str """ - super(RuleListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link @@ -2024,33 +1901,28 @@ class SBAuthorizationRule(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'rights': {'key': 'properties.rights', 'type': '[str]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "rights": {"key": "properties.rights", "type": "[str]"}, } - def __init__( - self, - *, - rights: Optional[List[Union[str, "_models.AccessRights"]]] = None, - **kwargs - ): + def __init__(self, *, rights: Optional[List[Union[str, "_models.AccessRights"]]] = None, **kwargs): """ :keyword rights: The rights associated with the rule. :paramtype rights: list[str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.AccessRights] """ - super(SBAuthorizationRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.rights = rights -class SBAuthorizationRuleListResult(msrest.serialization.Model): +class SBAuthorizationRuleListResult(_serialization.Model): """The response to the List Namespace operation. :ivar value: Result of the List Authorization Rules operation. @@ -2061,16 +1933,12 @@ class SBAuthorizationRuleListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[SBAuthorizationRule]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SBAuthorizationRule]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["_models.SBAuthorizationRule"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.SBAuthorizationRule"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Result of the List Authorization Rules operation. @@ -2079,7 +1947,7 @@ def __init__( list of Authorization Rules. :paramtype next_link: str """ - super(SBAuthorizationRuleListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link @@ -2097,46 +1965,40 @@ class TrackedResource(Resource): :vartype name: str :ivar type: Resource type. :vartype type: str - :ivar location: Required. The Geo-location where the resource lives. + :ivar location: The Geo-location where the resource lives. Required. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "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 Geo-location where the resource lives. + :keyword location: The Geo-location where the resource lives. Required. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] """ - super(TrackedResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.tags = tags -class SBNamespace(TrackedResource): +class SBNamespace(TrackedResource): # pylint: disable=too-many-instance-attributes """Description of a namespace resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -2149,9 +2011,9 @@ class SBNamespace(TrackedResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :ivar location: Required. The Geo-location where the resource lives. + :ivar location: The Geo-location where the resource lives. Required. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar sku: Properties of SKU. :vartype sku: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBSku @@ -2177,34 +2039,34 @@ class SBNamespace(TrackedResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'provisioning_state': {'readonly': True}, - 'status': {'readonly': True}, - 'created_at': {'readonly': True}, - 'updated_at': {'readonly': True}, - 'service_bus_endpoint': {'readonly': True}, - 'metric_id': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "provisioning_state": {"readonly": True}, + "status": {"readonly": True}, + "created_at": {"readonly": True}, + "updated_at": {"readonly": True}, + "service_bus_endpoint": {"readonly": True}, + "metric_id": {"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}'}, - 'sku': {'key': 'sku', 'type': 'SBSku'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'created_at': {'key': 'properties.createdAt', 'type': 'iso-8601'}, - 'updated_at': {'key': 'properties.updatedAt', 'type': 'iso-8601'}, - 'service_bus_endpoint': {'key': 'properties.serviceBusEndpoint', 'type': 'str'}, - 'metric_id': {'key': 'properties.metricId', 'type': 'str'}, - 'zone_redundant': {'key': 'properties.zoneRedundant', 'type': 'bool'}, - 'encryption': {'key': 'properties.encryption', 'type': 'Encryption'}, + "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}"}, + "sku": {"key": "sku", "type": "SBSku"}, + "identity": {"key": "identity", "type": "Identity"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "status": {"key": "properties.status", "type": "str"}, + "created_at": {"key": "properties.createdAt", "type": "iso-8601"}, + "updated_at": {"key": "properties.updatedAt", "type": "iso-8601"}, + "service_bus_endpoint": {"key": "properties.serviceBusEndpoint", "type": "str"}, + "metric_id": {"key": "properties.metricId", "type": "str"}, + "zone_redundant": {"key": "properties.zoneRedundant", "type": "bool"}, + "encryption": {"key": "properties.encryption", "type": "Encryption"}, } def __init__( @@ -2219,9 +2081,9 @@ def __init__( **kwargs ): """ - :keyword location: Required. The Geo-location where the resource lives. + :keyword location: The Geo-location where the resource lives. Required. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword sku: Properties of SKU. :paramtype sku: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBSku @@ -2233,7 +2095,7 @@ def __init__( :keyword encryption: Properties of BYOK Encryption description. :paramtype encryption: ~azure.mgmt.servicebus.v2018_01_01_preview.models.Encryption """ - super(SBNamespace, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.sku = sku self.identity = identity self.provisioning_state = None @@ -2246,7 +2108,7 @@ def __init__( self.encryption = encryption -class SBNamespaceListResult(msrest.serialization.Model): +class SBNamespaceListResult(_serialization.Model): """The response of the List Namespace operation. :ivar value: Result of the List Namespace operation. @@ -2257,16 +2119,12 @@ class SBNamespaceListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[SBNamespace]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SBNamespace]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["_models.SBNamespace"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.SBNamespace"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Result of the List Namespace operation. @@ -2275,47 +2133,42 @@ def __init__( list of Namespaces. :paramtype next_link: str """ - super(SBNamespaceListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class SBNamespaceMigrate(msrest.serialization.Model): +class SBNamespaceMigrate(_serialization.Model): """Namespace Migrate Object. All required parameters must be populated in order to send to Azure. - :ivar target_namespace_type: Required. Type of namespaces. Known values are: "Messaging", - "NotificationHub", "Mixed", "EventHub", "Relay". + :ivar target_namespace_type: Type of namespaces. Required. Known values are: "Messaging", + "NotificationHub", "Mixed", "EventHub", and "Relay". :vartype target_namespace_type: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.NameSpaceType """ _validation = { - 'target_namespace_type': {'required': True}, + "target_namespace_type": {"required": True}, } _attribute_map = { - 'target_namespace_type': {'key': 'targetNamespaceType', 'type': 'str'}, + "target_namespace_type": {"key": "targetNamespaceType", "type": "str"}, } - def __init__( - self, - *, - target_namespace_type: Union[str, "_models.NameSpaceType"], - **kwargs - ): + def __init__(self, *, target_namespace_type: Union[str, "_models.NameSpaceType"], **kwargs): """ - :keyword target_namespace_type: Required. Type of namespaces. Known values are: "Messaging", - "NotificationHub", "Mixed", "EventHub", "Relay". + :keyword target_namespace_type: Type of namespaces. Required. Known values are: "Messaging", + "NotificationHub", "Mixed", "EventHub", and "Relay". :paramtype target_namespace_type: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.NameSpaceType """ - super(SBNamespaceMigrate, self).__init__(**kwargs) + super().__init__(**kwargs) self.target_namespace_type = target_namespace_type -class SBNamespaceUpdateParameters(ResourceNamespacePatch): +class SBNamespaceUpdateParameters(ResourceNamespacePatch): # pylint: disable=too-many-instance-attributes """Description of a namespace resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -2328,7 +2181,7 @@ class SBNamespaceUpdateParameters(ResourceNamespacePatch): :vartype type: str :ivar location: Resource location. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar sku: Properties of SKU. :vartype sku: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBSku @@ -2354,33 +2207,33 @@ class SBNamespaceUpdateParameters(ResourceNamespacePatch): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'status': {'readonly': True}, - 'created_at': {'readonly': True}, - 'updated_at': {'readonly': True}, - 'service_bus_endpoint': {'readonly': True}, - 'metric_id': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "status": {"readonly": True}, + "created_at": {"readonly": True}, + "updated_at": {"readonly": True}, + "service_bus_endpoint": {"readonly": True}, + "metric_id": {"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}'}, - 'sku': {'key': 'sku', 'type': 'SBSku'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'created_at': {'key': 'properties.createdAt', 'type': 'iso-8601'}, - 'updated_at': {'key': 'properties.updatedAt', 'type': 'iso-8601'}, - 'service_bus_endpoint': {'key': 'properties.serviceBusEndpoint', 'type': 'str'}, - 'metric_id': {'key': 'properties.metricId', 'type': 'str'}, - 'zone_redundant': {'key': 'properties.zoneRedundant', 'type': 'bool'}, - 'encryption': {'key': 'properties.encryption', 'type': 'Encryption'}, + "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}"}, + "sku": {"key": "sku", "type": "SBSku"}, + "identity": {"key": "identity", "type": "Identity"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "status": {"key": "properties.status", "type": "str"}, + "created_at": {"key": "properties.createdAt", "type": "iso-8601"}, + "updated_at": {"key": "properties.updatedAt", "type": "iso-8601"}, + "service_bus_endpoint": {"key": "properties.serviceBusEndpoint", "type": "str"}, + "metric_id": {"key": "properties.metricId", "type": "str"}, + "zone_redundant": {"key": "properties.zoneRedundant", "type": "bool"}, + "encryption": {"key": "properties.encryption", "type": "Encryption"}, } def __init__( @@ -2397,7 +2250,7 @@ def __init__( """ :keyword location: Resource location. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword sku: Properties of SKU. :paramtype sku: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBSku @@ -2409,7 +2262,7 @@ def __init__( :keyword encryption: Properties of BYOK Encryption description. :paramtype encryption: ~azure.mgmt.servicebus.v2018_01_01_preview.models.Encryption """ - super(SBNamespaceUpdateParameters, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.sku = sku self.identity = identity self.provisioning_state = None @@ -2422,7 +2275,7 @@ def __init__( self.encryption = encryption -class SBQueue(Resource): +class SBQueue(Resource): # pylint: disable=too-many-instance-attributes """Description of queue Resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -2443,9 +2296,9 @@ class SBQueue(Resource): to this queue. :vartype accessed_at: ~datetime.datetime :ivar size_in_bytes: The size of the queue, in bytes. - :vartype size_in_bytes: long + :vartype size_in_bytes: int :ivar message_count: The number of messages in the queue. - :vartype message_count: long + :vartype message_count: int :ivar lock_duration: ISO 8601 timespan duration of a peek-lock; that is, the amount of time that the message is locked for other receivers. The maximum value for LockDuration is 5 minutes; the default value is 1 minute. @@ -2474,7 +2327,7 @@ class SBQueue(Resource): :vartype max_delivery_count: int :ivar status: Enumerates the possible values for the status of a messaging entity. Known values are: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", "Creating", - "Deleting", "Renaming", "Unknown". + "Deleting", "Renaming", and "Unknown". :vartype status: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.EntityStatus :ivar enable_batched_operations: Value that indicates whether server-side batched operations are enabled. @@ -2495,45 +2348,48 @@ class SBQueue(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'count_details': {'readonly': True}, - 'created_at': {'readonly': True}, - 'updated_at': {'readonly': True}, - 'accessed_at': {'readonly': True}, - 'size_in_bytes': {'readonly': True}, - 'message_count': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "count_details": {"readonly": True}, + "created_at": {"readonly": True}, + "updated_at": {"readonly": True}, + "accessed_at": {"readonly": True}, + "size_in_bytes": {"readonly": True}, + "message_count": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'count_details': {'key': 'properties.countDetails', 'type': 'MessageCountDetails'}, - 'created_at': {'key': 'properties.createdAt', 'type': 'iso-8601'}, - 'updated_at': {'key': 'properties.updatedAt', 'type': 'iso-8601'}, - 'accessed_at': {'key': 'properties.accessedAt', 'type': 'iso-8601'}, - 'size_in_bytes': {'key': 'properties.sizeInBytes', 'type': 'long'}, - 'message_count': {'key': 'properties.messageCount', 'type': 'long'}, - 'lock_duration': {'key': 'properties.lockDuration', 'type': 'duration'}, - 'max_size_in_megabytes': {'key': 'properties.maxSizeInMegabytes', 'type': 'int'}, - 'requires_duplicate_detection': {'key': 'properties.requiresDuplicateDetection', 'type': 'bool'}, - 'requires_session': {'key': 'properties.requiresSession', 'type': 'bool'}, - 'default_message_time_to_live': {'key': 'properties.defaultMessageTimeToLive', 'type': 'duration'}, - 'dead_lettering_on_message_expiration': {'key': 'properties.deadLetteringOnMessageExpiration', 'type': 'bool'}, - 'duplicate_detection_history_time_window': {'key': 'properties.duplicateDetectionHistoryTimeWindow', 'type': 'duration'}, - 'max_delivery_count': {'key': 'properties.maxDeliveryCount', 'type': 'int'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'enable_batched_operations': {'key': 'properties.enableBatchedOperations', 'type': 'bool'}, - 'auto_delete_on_idle': {'key': 'properties.autoDeleteOnIdle', 'type': 'duration'}, - 'enable_partitioning': {'key': 'properties.enablePartitioning', 'type': 'bool'}, - 'enable_express': {'key': 'properties.enableExpress', 'type': 'bool'}, - 'forward_to': {'key': 'properties.forwardTo', 'type': 'str'}, - 'forward_dead_lettered_messages_to': {'key': 'properties.forwardDeadLetteredMessagesTo', 'type': 'str'}, - } - - def __init__( + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "count_details": {"key": "properties.countDetails", "type": "MessageCountDetails"}, + "created_at": {"key": "properties.createdAt", "type": "iso-8601"}, + "updated_at": {"key": "properties.updatedAt", "type": "iso-8601"}, + "accessed_at": {"key": "properties.accessedAt", "type": "iso-8601"}, + "size_in_bytes": {"key": "properties.sizeInBytes", "type": "int"}, + "message_count": {"key": "properties.messageCount", "type": "int"}, + "lock_duration": {"key": "properties.lockDuration", "type": "duration"}, + "max_size_in_megabytes": {"key": "properties.maxSizeInMegabytes", "type": "int"}, + "requires_duplicate_detection": {"key": "properties.requiresDuplicateDetection", "type": "bool"}, + "requires_session": {"key": "properties.requiresSession", "type": "bool"}, + "default_message_time_to_live": {"key": "properties.defaultMessageTimeToLive", "type": "duration"}, + "dead_lettering_on_message_expiration": {"key": "properties.deadLetteringOnMessageExpiration", "type": "bool"}, + "duplicate_detection_history_time_window": { + "key": "properties.duplicateDetectionHistoryTimeWindow", + "type": "duration", + }, + "max_delivery_count": {"key": "properties.maxDeliveryCount", "type": "int"}, + "status": {"key": "properties.status", "type": "str"}, + "enable_batched_operations": {"key": "properties.enableBatchedOperations", "type": "bool"}, + "auto_delete_on_idle": {"key": "properties.autoDeleteOnIdle", "type": "duration"}, + "enable_partitioning": {"key": "properties.enablePartitioning", "type": "bool"}, + "enable_express": {"key": "properties.enableExpress", "type": "bool"}, + "forward_to": {"key": "properties.forwardTo", "type": "str"}, + "forward_dead_lettered_messages_to": {"key": "properties.forwardDeadLetteredMessagesTo", "type": "str"}, + } + + def __init__( # pylint: disable=too-many-locals self, *, lock_duration: Optional[datetime.timedelta] = None, @@ -2582,7 +2438,7 @@ def __init__( :paramtype max_delivery_count: int :keyword status: Enumerates the possible values for the status of a messaging entity. Known values are: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", "Creating", - "Deleting", "Renaming", "Unknown". + "Deleting", "Renaming", and "Unknown". :paramtype status: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.EntityStatus :keyword enable_batched_operations: Value that indicates whether server-side batched operations are enabled. @@ -2602,7 +2458,7 @@ def __init__( message. :paramtype forward_dead_lettered_messages_to: str """ - super(SBQueue, self).__init__(**kwargs) + super().__init__(**kwargs) self.count_details = None self.created_at = None self.updated_at = None @@ -2626,7 +2482,7 @@ def __init__( self.forward_dead_lettered_messages_to = forward_dead_lettered_messages_to -class SBQueueListResult(msrest.serialization.Model): +class SBQueueListResult(_serialization.Model): """The response to the List Queues operation. :ivar value: Result of the List Queues operation. @@ -2637,17 +2493,11 @@ class SBQueueListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[SBQueue]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SBQueue]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["_models.SBQueue"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.SBQueue"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: Result of the List Queues operation. :paramtype value: list[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBQueue] @@ -2655,19 +2505,19 @@ def __init__( list of queues. :paramtype next_link: str """ - super(SBQueueListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class SBSku(msrest.serialization.Model): +class SBSku(_serialization.Model): """SKU of the namespace. All required parameters must be populated in order to send to Azure. - :ivar name: Required. Name of this SKU. Known values are: "Basic", "Standard", "Premium". + :ivar name: Name of this SKU. Required. Known values are: "Basic", "Standard", and "Premium". :vartype name: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.SkuName - :ivar tier: The billing tier of this particular SKU. Known values are: "Basic", "Standard", + :ivar tier: The billing tier of this particular SKU. Known values are: "Basic", "Standard", and "Premium". :vartype tier: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.SkuTier :ivar capacity: The specified messaging units for the tier. For Premium tier, capacity are 1,2 @@ -2676,13 +2526,13 @@ class SBSku(msrest.serialization.Model): """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'capacity': {'key': 'capacity', 'type': 'int'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "capacity": {"key": "capacity", "type": "int"}, } def __init__( @@ -2694,22 +2544,23 @@ def __init__( **kwargs ): """ - :keyword name: Required. Name of this SKU. Known values are: "Basic", "Standard", "Premium". + :keyword name: Name of this SKU. Required. Known values are: "Basic", "Standard", and + "Premium". :paramtype name: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.SkuName :keyword tier: The billing tier of this particular SKU. Known values are: "Basic", "Standard", - "Premium". + and "Premium". :paramtype tier: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.SkuTier :keyword capacity: The specified messaging units for the tier. For Premium tier, capacity are 1,2 and 4. :paramtype capacity: int """ - super(SBSku, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.tier = tier self.capacity = capacity -class SBSubscription(Resource): +class SBSubscription(Resource): # pylint: disable=too-many-instance-attributes """Description of subscription resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -2721,7 +2572,7 @@ class SBSubscription(Resource): :ivar type: Resource type. :vartype type: str :ivar message_count: Number of messages. - :vartype message_count: long + :vartype message_count: int :ivar created_at: Exact time the message was created. :vartype created_at: ~datetime.datetime :ivar accessed_at: Last time there was a receive request to this subscription. @@ -2752,7 +2603,7 @@ class SBSubscription(Resource): :vartype max_delivery_count: int :ivar status: Enumerates the possible values for the status of a messaging entity. Known values are: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", "Creating", - "Deleting", "Renaming", "Unknown". + "Deleting", "Renaming", and "Unknown". :vartype status: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.EntityStatus :ivar enable_batched_operations: Value that indicates whether server-side batched operations are enabled. @@ -2767,37 +2618,43 @@ class SBSubscription(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'message_count': {'readonly': True}, - 'created_at': {'readonly': True}, - 'accessed_at': {'readonly': True}, - 'updated_at': {'readonly': True}, - 'count_details': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "message_count": {"readonly": True}, + "created_at": {"readonly": True}, + "accessed_at": {"readonly": True}, + "updated_at": {"readonly": True}, + "count_details": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'message_count': {'key': 'properties.messageCount', 'type': 'long'}, - 'created_at': {'key': 'properties.createdAt', 'type': 'iso-8601'}, - 'accessed_at': {'key': 'properties.accessedAt', 'type': 'iso-8601'}, - 'updated_at': {'key': 'properties.updatedAt', 'type': 'iso-8601'}, - 'count_details': {'key': 'properties.countDetails', 'type': 'MessageCountDetails'}, - 'lock_duration': {'key': 'properties.lockDuration', 'type': 'duration'}, - 'requires_session': {'key': 'properties.requiresSession', 'type': 'bool'}, - 'default_message_time_to_live': {'key': 'properties.defaultMessageTimeToLive', 'type': 'duration'}, - 'dead_lettering_on_filter_evaluation_exceptions': {'key': 'properties.deadLetteringOnFilterEvaluationExceptions', 'type': 'bool'}, - 'dead_lettering_on_message_expiration': {'key': 'properties.deadLetteringOnMessageExpiration', 'type': 'bool'}, - 'duplicate_detection_history_time_window': {'key': 'properties.duplicateDetectionHistoryTimeWindow', 'type': 'duration'}, - 'max_delivery_count': {'key': 'properties.maxDeliveryCount', 'type': 'int'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'enable_batched_operations': {'key': 'properties.enableBatchedOperations', 'type': 'bool'}, - 'auto_delete_on_idle': {'key': 'properties.autoDeleteOnIdle', 'type': 'duration'}, - 'forward_to': {'key': 'properties.forwardTo', 'type': 'str'}, - 'forward_dead_lettered_messages_to': {'key': 'properties.forwardDeadLetteredMessagesTo', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "message_count": {"key": "properties.messageCount", "type": "int"}, + "created_at": {"key": "properties.createdAt", "type": "iso-8601"}, + "accessed_at": {"key": "properties.accessedAt", "type": "iso-8601"}, + "updated_at": {"key": "properties.updatedAt", "type": "iso-8601"}, + "count_details": {"key": "properties.countDetails", "type": "MessageCountDetails"}, + "lock_duration": {"key": "properties.lockDuration", "type": "duration"}, + "requires_session": {"key": "properties.requiresSession", "type": "bool"}, + "default_message_time_to_live": {"key": "properties.defaultMessageTimeToLive", "type": "duration"}, + "dead_lettering_on_filter_evaluation_exceptions": { + "key": "properties.deadLetteringOnFilterEvaluationExceptions", + "type": "bool", + }, + "dead_lettering_on_message_expiration": {"key": "properties.deadLetteringOnMessageExpiration", "type": "bool"}, + "duplicate_detection_history_time_window": { + "key": "properties.duplicateDetectionHistoryTimeWindow", + "type": "duration", + }, + "max_delivery_count": {"key": "properties.maxDeliveryCount", "type": "int"}, + "status": {"key": "properties.status", "type": "str"}, + "enable_batched_operations": {"key": "properties.enableBatchedOperations", "type": "bool"}, + "auto_delete_on_idle": {"key": "properties.autoDeleteOnIdle", "type": "duration"}, + "forward_to": {"key": "properties.forwardTo", "type": "str"}, + "forward_dead_lettered_messages_to": {"key": "properties.forwardDeadLetteredMessagesTo", "type": "str"}, } def __init__( @@ -2840,7 +2697,7 @@ def __init__( :paramtype max_delivery_count: int :keyword status: Enumerates the possible values for the status of a messaging entity. Known values are: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", "Creating", - "Deleting", "Renaming", "Unknown". + "Deleting", "Renaming", and "Unknown". :paramtype status: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.EntityStatus :keyword enable_batched_operations: Value that indicates whether server-side batched operations are enabled. @@ -2854,7 +2711,7 @@ def __init__( message. :paramtype forward_dead_lettered_messages_to: str """ - super(SBSubscription, self).__init__(**kwargs) + super().__init__(**kwargs) self.message_count = None self.created_at = None self.accessed_at = None @@ -2874,7 +2731,7 @@ def __init__( self.forward_dead_lettered_messages_to = forward_dead_lettered_messages_to -class SBSubscriptionListResult(msrest.serialization.Model): +class SBSubscriptionListResult(_serialization.Model): """The response to the List Subscriptions operation. :ivar value: Result of the List Subscriptions operation. @@ -2885,16 +2742,12 @@ class SBSubscriptionListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[SBSubscription]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SBSubscription]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["_models.SBSubscription"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.SBSubscription"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Result of the List Subscriptions operation. @@ -2903,12 +2756,12 @@ def __init__( list of subscriptions. :paramtype next_link: str """ - super(SBSubscriptionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class SBTopic(Resource): +class SBTopic(Resource): # pylint: disable=too-many-instance-attributes """Description of topic resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -2920,7 +2773,7 @@ class SBTopic(Resource): :ivar type: Resource type. :vartype type: str :ivar size_in_bytes: Size of the topic, in bytes. - :vartype size_in_bytes: long + :vartype size_in_bytes: int :ivar created_at: Exact time the message was created. :vartype created_at: ~datetime.datetime :ivar updated_at: The exact time the message was updated. @@ -2949,7 +2802,7 @@ class SBTopic(Resource): :vartype enable_batched_operations: bool :ivar status: Enumerates the possible values for the status of a messaging entity. Known values are: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", "Creating", - "Deleting", "Renaming", "Unknown". + "Deleting", "Renaming", and "Unknown". :vartype status: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.EntityStatus :ivar support_ordering: Value that indicates whether the topic supports ordering. :vartype support_ordering: bool @@ -2965,37 +2818,40 @@ class SBTopic(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'size_in_bytes': {'readonly': True}, - 'created_at': {'readonly': True}, - 'updated_at': {'readonly': True}, - 'accessed_at': {'readonly': True}, - 'subscription_count': {'readonly': True}, - 'count_details': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "size_in_bytes": {"readonly": True}, + "created_at": {"readonly": True}, + "updated_at": {"readonly": True}, + "accessed_at": {"readonly": True}, + "subscription_count": {"readonly": True}, + "count_details": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'size_in_bytes': {'key': 'properties.sizeInBytes', 'type': 'long'}, - 'created_at': {'key': 'properties.createdAt', 'type': 'iso-8601'}, - 'updated_at': {'key': 'properties.updatedAt', 'type': 'iso-8601'}, - 'accessed_at': {'key': 'properties.accessedAt', 'type': 'iso-8601'}, - 'subscription_count': {'key': 'properties.subscriptionCount', 'type': 'int'}, - 'count_details': {'key': 'properties.countDetails', 'type': 'MessageCountDetails'}, - 'default_message_time_to_live': {'key': 'properties.defaultMessageTimeToLive', 'type': 'duration'}, - 'max_size_in_megabytes': {'key': 'properties.maxSizeInMegabytes', 'type': 'int'}, - 'requires_duplicate_detection': {'key': 'properties.requiresDuplicateDetection', 'type': 'bool'}, - 'duplicate_detection_history_time_window': {'key': 'properties.duplicateDetectionHistoryTimeWindow', 'type': 'duration'}, - 'enable_batched_operations': {'key': 'properties.enableBatchedOperations', 'type': 'bool'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'support_ordering': {'key': 'properties.supportOrdering', 'type': 'bool'}, - 'auto_delete_on_idle': {'key': 'properties.autoDeleteOnIdle', 'type': 'duration'}, - 'enable_partitioning': {'key': 'properties.enablePartitioning', 'type': 'bool'}, - 'enable_express': {'key': 'properties.enableExpress', 'type': 'bool'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "size_in_bytes": {"key": "properties.sizeInBytes", "type": "int"}, + "created_at": {"key": "properties.createdAt", "type": "iso-8601"}, + "updated_at": {"key": "properties.updatedAt", "type": "iso-8601"}, + "accessed_at": {"key": "properties.accessedAt", "type": "iso-8601"}, + "subscription_count": {"key": "properties.subscriptionCount", "type": "int"}, + "count_details": {"key": "properties.countDetails", "type": "MessageCountDetails"}, + "default_message_time_to_live": {"key": "properties.defaultMessageTimeToLive", "type": "duration"}, + "max_size_in_megabytes": {"key": "properties.maxSizeInMegabytes", "type": "int"}, + "requires_duplicate_detection": {"key": "properties.requiresDuplicateDetection", "type": "bool"}, + "duplicate_detection_history_time_window": { + "key": "properties.duplicateDetectionHistoryTimeWindow", + "type": "duration", + }, + "enable_batched_operations": {"key": "properties.enableBatchedOperations", "type": "bool"}, + "status": {"key": "properties.status", "type": "str"}, + "support_ordering": {"key": "properties.supportOrdering", "type": "bool"}, + "auto_delete_on_idle": {"key": "properties.autoDeleteOnIdle", "type": "duration"}, + "enable_partitioning": {"key": "properties.enablePartitioning", "type": "bool"}, + "enable_express": {"key": "properties.enableExpress", "type": "bool"}, } def __init__( @@ -3032,7 +2888,7 @@ def __init__( :paramtype enable_batched_operations: bool :keyword status: Enumerates the possible values for the status of a messaging entity. Known values are: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", "Creating", - "Deleting", "Renaming", "Unknown". + "Deleting", "Renaming", and "Unknown". :paramtype status: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.EntityStatus :keyword support_ordering: Value that indicates whether the topic supports ordering. :paramtype support_ordering: bool @@ -3046,7 +2902,7 @@ def __init__( topic holds a message in memory temporarily before writing it to persistent storage. :paramtype enable_express: bool """ - super(SBTopic, self).__init__(**kwargs) + super().__init__(**kwargs) self.size_in_bytes = None self.created_at = None self.updated_at = None @@ -3065,7 +2921,7 @@ def __init__( self.enable_express = enable_express -class SBTopicListResult(msrest.serialization.Model): +class SBTopicListResult(_serialization.Model): """The response to the List Topics operation. :ivar value: Result of the List Topics operation. @@ -3076,17 +2932,11 @@ class SBTopicListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[SBTopic]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SBTopic]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["_models.SBTopic"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.SBTopic"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: Result of the List Topics operation. :paramtype value: list[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBTopic] @@ -3094,12 +2944,12 @@ def __init__( list of topics. :paramtype next_link: str """ - super(SBTopicListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class SqlFilter(msrest.serialization.Model): +class SqlFilter(_serialization.Model): """Represents a filter which is a composition of an expression and an action that is executed in the pub/sub pipeline. :ivar sql_expression: The SQL expression. e.g. MyProperty='ABC'. @@ -3113,21 +2963,21 @@ class SqlFilter(msrest.serialization.Model): """ _validation = { - 'compatibility_level': {'maximum': 20, 'minimum': 20}, + "compatibility_level": {"maximum": 20, "minimum": 20}, } _attribute_map = { - 'sql_expression': {'key': 'sqlExpression', 'type': 'str'}, - 'compatibility_level': {'key': 'compatibilityLevel', 'type': 'int'}, - 'requires_preprocessing': {'key': 'requiresPreprocessing', 'type': 'bool'}, + "sql_expression": {"key": "sqlExpression", "type": "str"}, + "compatibility_level": {"key": "compatibilityLevel", "type": "int"}, + "requires_preprocessing": {"key": "requiresPreprocessing", "type": "bool"}, } def __init__( self, *, sql_expression: Optional[str] = None, - compatibility_level: Optional[int] = 20, - requires_preprocessing: Optional[bool] = True, + compatibility_level: int = 20, + requires_preprocessing: bool = True, **kwargs ): """ @@ -3140,7 +2990,7 @@ def __init__( preprocessing. :paramtype requires_preprocessing: bool """ - super(SqlFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.sql_expression = sql_expression self.compatibility_level = compatibility_level self.requires_preprocessing = requires_preprocessing @@ -3160,9 +3010,9 @@ class SqlRuleAction(Action): """ _attribute_map = { - 'sql_expression': {'key': 'sqlExpression', 'type': 'str'}, - 'compatibility_level': {'key': 'compatibilityLevel', 'type': 'int'}, - 'requires_preprocessing': {'key': 'requiresPreprocessing', 'type': 'bool'}, + "sql_expression": {"key": "sqlExpression", "type": "str"}, + "compatibility_level": {"key": "compatibilityLevel", "type": "int"}, + "requires_preprocessing": {"key": "requiresPreprocessing", "type": "bool"}, } def __init__( @@ -3170,7 +3020,7 @@ def __init__( *, sql_expression: Optional[str] = None, compatibility_level: Optional[int] = None, - requires_preprocessing: Optional[bool] = True, + requires_preprocessing: bool = True, **kwargs ): """ @@ -3183,37 +3033,37 @@ def __init__( preprocessing. :paramtype requires_preprocessing: bool """ - super(SqlRuleAction, self).__init__(sql_expression=sql_expression, compatibility_level=compatibility_level, requires_preprocessing=requires_preprocessing, **kwargs) + super().__init__( + sql_expression=sql_expression, + compatibility_level=compatibility_level, + requires_preprocessing=requires_preprocessing, + **kwargs + ) -class Subnet(msrest.serialization.Model): +class Subnet(_serialization.Model): """Properties supplied for Subnet. All required parameters must be populated in order to send to Azure. - :ivar id: Required. Resource ID of Virtual Network Subnet. + :ivar id: Resource ID of Virtual Network Subnet. Required. :vartype id: str """ _validation = { - 'id': {'required': True}, + "id": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - *, - id: str, - **kwargs - ): + def __init__(self, *, id: str, **kwargs): # pylint: disable=redefined-builtin """ - :keyword id: Required. Resource ID of Virtual Network Subnet. + :keyword id: Resource ID of Virtual Network Subnet. Required. :paramtype id: str """ - super(Subnet, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id @@ -3233,33 +3083,28 @@ class VirtualNetworkRule(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'virtual_network_subnet_id': {'key': 'properties.virtualNetworkSubnetId', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "virtual_network_subnet_id": {"key": "properties.virtualNetworkSubnetId", "type": "str"}, } - def __init__( - self, - *, - virtual_network_subnet_id: Optional[str] = None, - **kwargs - ): + def __init__(self, *, virtual_network_subnet_id: Optional[str] = None, **kwargs): """ :keyword virtual_network_subnet_id: Resource ID of Virtual Network Subnet. :paramtype virtual_network_subnet_id: str """ - super(VirtualNetworkRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.virtual_network_subnet_id = virtual_network_subnet_id -class VirtualNetworkRuleListResult(msrest.serialization.Model): +class VirtualNetworkRuleListResult(_serialization.Model): """The response from the List namespace operation. :ivar value: Result of the List VirtualNetwork Rules operation. @@ -3270,16 +3115,12 @@ class VirtualNetworkRuleListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[VirtualNetworkRule]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[VirtualNetworkRule]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["_models.VirtualNetworkRule"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.VirtualNetworkRule"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Result of the List VirtualNetwork Rules operation. @@ -3288,6 +3129,6 @@ def __init__( list of VirtualNetwork Rules. :paramtype next_link: str """ - super(VirtualNetworkRuleListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/models/_patch.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/models/_patch.py index 0ad201a8c586e..f7dd32510333d 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/models/_patch.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/models/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/models/_service_bus_management_client_enums.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/models/_service_bus_management_client_enums.py index cf94f7f2109d1..af42f8afb68f5 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/models/_service_bus_management_client_enums.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/models/_service_bus_management_client_enums.py @@ -11,28 +11,29 @@ class AccessRights(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """AccessRights.""" MANAGE = "Manage" SEND = "Send" LISTEN = "Listen" + class DefaultAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Default Action for Network Rule Set - """ + """Default Action for Network Rule Set.""" ALLOW = "Allow" DENY = "Deny" + class EncodingCaptureDescription(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Enumerates the possible values for the encoding format of capture description. - """ + """Enumerates the possible values for the encoding format of capture description.""" AVRO = "Avro" AVRO_DEFLATE = "AvroDeflate" + class EndPointProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Provisioning state of the Private Endpoint Connection. - """ + """Provisioning state of the Private Endpoint Connection.""" CREATING = "Creating" UPDATING = "Updating" @@ -41,9 +42,9 @@ class EndPointProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): CANCELED = "Canceled" FAILED = "Failed" + class EntityStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Entity status. - """ + """Entity status.""" ACTIVE = "Active" DISABLED = "Disabled" @@ -55,34 +56,36 @@ class EntityStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): RENAMING = "Renaming" UNKNOWN = "Unknown" + class FilterType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Rule filter types - """ + """Rule filter types.""" SQL_FILTER = "SqlFilter" CORRELATION_FILTER = "CorrelationFilter" + class IPAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The IP Filter Action - """ + """The IP Filter Action.""" ACCEPT = "Accept" REJECT = "Reject" + class KeyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The access key to regenerate. - """ + """The access key to regenerate.""" PRIMARY_KEY = "PrimaryKey" SECONDARY_KEY = "SecondaryKey" + class MigrationConfigurationName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """MigrationConfigurationName.""" _DEFAULT = "$default" + class NameSpaceType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Type of namespaces - """ + """Type of namespaces.""" MESSAGING = "Messaging" NOTIFICATION_HUB = "NotificationHub" @@ -90,58 +93,60 @@ class NameSpaceType(str, Enum, metaclass=CaseInsensitiveEnumMeta): EVENT_HUB = "EventHub" RELAY = "Relay" + class NetworkRuleIPAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The IP Filter Action - """ + """The IP Filter Action.""" ALLOW = "Allow" + class PrivateLinkConnectionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Status of the connection. - """ + """Status of the connection.""" PENDING = "Pending" APPROVED = "Approved" REJECTED = "Rejected" DISCONNECTED = "Disconnected" + class ProvisioningStateDR(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Provisioning state of the Alias(Disaster Recovery configuration) - possible values 'Accepted' - or 'Succeeded' or 'Failed' + or 'Succeeded' or 'Failed'. """ ACCEPTED = "Accepted" SUCCEEDED = "Succeeded" FAILED = "Failed" + class RoleDisasterRecovery(str, Enum, metaclass=CaseInsensitiveEnumMeta): """role of namespace in GEO DR - possible values 'Primary' or 'PrimaryNotReplicating' or - 'Secondary' + 'Secondary'. """ PRIMARY = "Primary" PRIMARY_NOT_REPLICATING = "PrimaryNotReplicating" SECONDARY = "Secondary" + class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Name of this SKU. - """ + """Name of this SKU.""" BASIC = "Basic" STANDARD = "Standard" PREMIUM = "Premium" + class SkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The billing tier of this particular SKU. - """ + """The billing tier of this particular SKU.""" BASIC = "Basic" STANDARD = "Standard" PREMIUM = "Premium" + class UnavailableReason(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the reason for the unavailability of the service. - """ + """Specifies the reason for the unavailability of the service.""" NONE = "None" INVALID_NAME = "InvalidName" diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/__init__.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/__init__.py index a21798eafb6a6..7209ae0760257 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/__init__.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/__init__.py @@ -21,22 +21,23 @@ from ._operations import Operations from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'NamespacesOperations', - 'PrivateEndpointConnectionsOperations', - 'PrivateLinkResourcesOperations', - 'DisasterRecoveryConfigsOperations', - 'QueuesOperations', - 'TopicsOperations', - 'EventHubsOperations', - 'MigrationConfigsOperations', - 'PremiumMessagingRegionsOperations', - 'RegionsOperations', - 'SubscriptionsOperations', - 'RulesOperations', - 'Operations', + "NamespacesOperations", + "PrivateEndpointConnectionsOperations", + "PrivateLinkResourcesOperations", + "DisasterRecoveryConfigsOperations", + "QueuesOperations", + "TopicsOperations", + "EventHubsOperations", + "MigrationConfigsOperations", + "PremiumMessagingRegionsOperations", + "RegionsOperations", + "SubscriptionsOperations", + "RulesOperations", + "Operations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_disaster_recovery_configs_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_disaster_recovery_configs_operations.py index 0f566aa173b33..970a6206539ac 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_disaster_recovery_configs_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_disaster_recovery_configs_operations.py @@ -6,11 +6,18 @@ # 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 msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,343 +27,313 @@ 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') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_check_name_availability_request( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - *, - json: Optional[_models.CheckNameAvailability] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_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-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: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/CheckNameAvailability") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/CheckNameAvailability", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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, - 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_request( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_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-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _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, - namespace_name: str, - alias: str, - subscription_id: str, - *, - json: Optional[_models.ArmDisasterRecovery] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_name: str, alias: 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-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: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "alias": _SERIALIZER.url("alias", alias, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "alias": _SERIALIZER.url("alias", alias, "str", max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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, - 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( - resource_group_name: str, - namespace_name: str, - alias: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, alias: 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-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "alias": _SERIALIZER.url("alias", alias, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "alias": _SERIALIZER.url("alias", alias, "str", max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - namespace_name: str, - alias: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, alias: 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-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "alias": _SERIALIZER.url("alias", alias, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "alias": _SERIALIZER.url("alias", alias, "str", max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_break_pairing_request( - resource_group_name: str, - namespace_name: str, - alias: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, alias: 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-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/breakPairing") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/breakPairing", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "alias": _SERIALIZER.url("alias", alias, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "alias": _SERIALIZER.url("alias", alias, "str", max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_fail_over_request( - resource_group_name: str, - namespace_name: str, - alias: str, - subscription_id: str, - *, - json: Optional[_models.FailoverProperties] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_name: str, alias: 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-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: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/failover") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/failover", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "alias": _SERIALIZER.url("alias", alias, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "alias": _SERIALIZER.url("alias", alias, "str", max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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, - 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_authorization_rules_request( - resource_group_name: str, - namespace_name: str, - alias: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, alias: 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-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "alias": _SERIALIZER.url("alias", alias, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "alias": _SERIALIZER.url("alias", alias, "str", max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_authorization_rule_request( @@ -370,34 +347,37 @@ def build_get_authorization_rule_request( _headers = case_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-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules/{authorizationRuleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "alias": _SERIALIZER.url("alias", alias, 'str', max_length=50, min_length=1), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "alias": _SERIALIZER.url("alias", alias, "str", max_length=50, min_length=1), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_keys_request( @@ -411,34 +391,38 @@ def build_list_keys_request( _headers = case_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-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules/{authorizationRuleName}/listKeys") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules/{authorizationRuleName}/listKeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "alias": _SERIALIZER.url("alias", alias, 'str', max_length=50, min_length=1), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "alias": _SERIALIZER.url("alias", alias, "str", max_length=50, min_length=1), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + class DisasterRecoveryConfigsOperations: """ @@ -459,41 +443,109 @@ def __init__(self, *args, **kwargs): 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 + @overload def check_name_availability( self, resource_group_name: str, namespace_name: str, parameters: _models.CheckNameAvailability, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Check the give namespace name availability. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: Parameters to check availability of the given namespace name. + :param parameters: Parameters to check availability of the given namespace name. Required. :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.CheckNameAvailability + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckNameAvailabilityResult or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters to check availability of the given namespace name. Required. + :type 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: CheckNameAvailabilityResult or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_name_availability( + self, + resource_group_name: str, + namespace_name: str, + parameters: Union[_models.CheckNameAvailability, IO], + **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters to check availability of the given namespace name. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.CheckNameAvailability 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: CheckNameAvailabilityResult, or the result of cls(response) + :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.CheckNameAvailabilityResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.CheckNameAvailabilityResult] - - _json = self._serialize.body(parameters, 'CheckNameAvailability') + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CheckNameAvailabilityResult] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "CheckNameAvailability") request = build_check_name_availability_request( resource_group_name=resource_group_name, @@ -502,18 +554,18 @@ def check_name_availability( 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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -521,74 +573,79 @@ def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) + deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/CheckNameAvailability"} # type: ignore - + check_name_availability.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/CheckNameAvailability" + } @distributed_trace def list( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> Iterable[_models.ArmDisasterRecoveryListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> Iterable["_models.ArmDisasterRecovery"]: """Gets all Alias(Disaster Recovery configurations). - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ArmDisasterRecoveryListResult or the result of - cls(response) + :return: An iterator like instance of either ArmDisasterRecovery or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.ArmDisasterRecoveryListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.ArmDisasterRecovery] + :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', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ArmDisasterRecoveryListResult] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[_models.ArmDisasterRecoveryListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -596,16 +653,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("ArmDisasterRecoveryListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -616,49 +671,126 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs" + } - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, namespace_name: str, alias: str, parameters: _models.ArmDisasterRecovery, + *, + content_type: str = "application/json", **kwargs: Any ) -> Optional[_models.ArmDisasterRecovery]: """Creates or updates a new Alias(Disaster Recovery configuration). - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: str :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). + Required. :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.ArmDisasterRecovery + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ArmDisasterRecovery, or the result of cls(response) + :return: ArmDisasterRecovery or None or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.ArmDisasterRecovery or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + alias: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> Optional[_models.ArmDisasterRecovery]: + """Creates or updates a new Alias(Disaster Recovery configuration). + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: str + :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). + Required. + :type 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: ArmDisasterRecovery or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.ArmDisasterRecovery or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + alias: str, + parameters: Union[_models.ArmDisasterRecovery, IO], + **kwargs: Any + ) -> Optional[_models.ArmDisasterRecovery]: + """Creates or updates a new Alias(Disaster Recovery configuration). + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: str + :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). Is + either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.ArmDisasterRecovery 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: ArmDisasterRecovery or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.ArmDisasterRecovery or None + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ArmDisasterRecovery]] - - _json = self._serialize.body(parameters, 'ArmDisasterRecovery') + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.ArmDisasterRecovery]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ArmDisasterRecovery") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -668,18 +800,18 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - 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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -689,67 +821,67 @@ def create_or_update( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ArmDisasterRecovery', pipeline_response) + deserialized = self._deserialize("ArmDisasterRecovery", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}"} # type: ignore - + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}" + } @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - alias: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, alias: str, **kwargs: Any ) -> None: """Deletes an Alias(Disaster Recovery configuration). - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: 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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, alias=alias, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -760,60 +892,60 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}"} # type: ignore - + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}" + } @distributed_trace def get( - self, - resource_group_name: str, - namespace_name: str, - alias: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, alias: str, **kwargs: Any ) -> _models.ArmDisasterRecovery: """Retrieves Alias(Disaster Recovery configuration) for primary or secondary namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ArmDisasterRecovery, or the result of cls(response) + :return: ArmDisasterRecovery or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.ArmDisasterRecovery - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ArmDisasterRecovery] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[_models.ArmDisasterRecovery] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, alias=alias, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -821,68 +953,68 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ArmDisasterRecovery', pipeline_response) + deserialized = self._deserialize("ArmDisasterRecovery", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}" + } @distributed_trace def break_pairing( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - alias: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, alias: str, **kwargs: Any ) -> None: """This operation disables the Disaster Recovery and stops replicating changes from primary to secondary namespaces. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: 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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_break_pairing_request( resource_group_name=resource_group_name, namespace_name=namespace_name, alias=alias, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.break_pairing.metadata['url'], + template_url=self.break_pairing.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -893,50 +1025,127 @@ def break_pairing( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - break_pairing.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/breakPairing"} # type: ignore - + break_pairing.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/breakPairing" + } - @distributed_trace + @overload def fail_over( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, alias: str, parameters: Optional[_models.FailoverProperties] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> None: """Invokes GEO DR failover and reconfigure the alias to point to the secondary namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: str :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). Default value is None. :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.FailoverProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default 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: + """ + + @overload + def fail_over( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + namespace_name: str, + alias: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Invokes GEO DR failover and reconfigure the alias to point to the secondary namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: str + :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). + Default value is None. + :type 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: 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: + """ + + @distributed_trace + def fail_over( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + namespace_name: str, + alias: str, + parameters: Optional[Union[_models.FailoverProperties, IO]] = None, + **kwargs: Any + ) -> None: + """Invokes GEO DR failover and reconfigure the alias to point to the secondary namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: str + :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). Is + either a model type or a IO type. Default value is None. + :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.FailoverProperties 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: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[None] - - if parameters is not None: - _json = self._serialize.body(parameters, 'FailoverProperties') + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "FailoverProperties") + else: + _json = None request = build_fail_over_request( resource_group_name=resource_group_name, @@ -946,18 +1155,18 @@ def fail_over( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, json=_json, - template_url=self.fail_over.metadata['url'], + content=_content, + template_url=self.fail_over.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -968,72 +1177,75 @@ def fail_over( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - fail_over.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/failover"} # type: ignore - + fail_over.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/failover" + } @distributed_trace def list_authorization_rules( - self, - resource_group_name: str, - namespace_name: str, - alias: str, - **kwargs: Any - ) -> Iterable[_models.SBAuthorizationRuleListResult]: + self, resource_group_name: str, namespace_name: str, alias: str, **kwargs: Any + ) -> Iterable["_models.SBAuthorizationRule"]: """Gets the authorization rules for a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of - cls(response) + :return: An iterator like instance of either SBAuthorizationRule or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRule] + :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', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRuleListResult] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[_models.SBAuthorizationRuleListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_authorization_rules_request( resource_group_name=resource_group_name, namespace_name=namespace_name, alias=alias, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_authorization_rules.metadata['url'], + template_url=self.list_authorization_rules.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_authorization_rules_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - alias=alias, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -1041,16 +1253,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("SBAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1061,48 +1271,47 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_authorization_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules"} # type: ignore + list_authorization_rules.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules" + } @distributed_trace def get_authorization_rule( - self, - resource_group_name: str, - namespace_name: str, - alias: str, - authorization_rule_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, alias: str, authorization_rule_name: str, **kwargs: Any ) -> _models.SBAuthorizationRule: """Gets an authorization rule for a namespace by rule name. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[_models.SBAuthorizationRule] = kwargs.pop("cls", None) - request = build_get_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -1110,18 +1319,17 @@ def get_authorization_rule( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_authorization_rule.metadata['url'], + template_url=self.get_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1129,52 +1337,52 @@ def get_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules/{authorizationRuleName}"} # type: ignore - + get_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules/{authorizationRuleName}" + } @distributed_trace def list_keys( - self, - resource_group_name: str, - namespace_name: str, - alias: str, - authorization_rule_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, alias: str, authorization_rule_name: str, **kwargs: Any ) -> _models.AccessKeys: """Gets the primary and secondary connection strings for the namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[_models.AccessKeys] = kwargs.pop("cls", None) - request = build_list_keys_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -1182,18 +1390,17 @@ def list_keys( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata['url'], + 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 + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1201,12 +1408,13 @@ def list_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + deserialized = self._deserialize("AccessKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules/{authorizationRuleName}/listKeys"} # type: ignore - + list_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules/{authorizationRuleName}/listKeys" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_event_hubs_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_event_hubs_operations.py index 1cbbff68b736d..1ff9a7a8ff595 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_event_hubs_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_event_hubs_operations.py @@ -6,11 +6,18 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,48 +27,54 @@ 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') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +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_namespace_request( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_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-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/eventhubs") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/eventhubs", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + class EventHubsOperations: """ @@ -82,64 +95,68 @@ def __init__(self, *args, **kwargs): 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_namespace( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> Iterable[_models.EventHubListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> Iterable["_models.Eventhub"]: """Gets all the Event Hubs in a service bus Namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventHubListResult or the result of cls(response) + :return: An iterator like instance of either Eventhub or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.EventHubListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.Eventhub] + :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', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.EventHubListResult] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[_models.EventHubListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_namespace_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_namespace.metadata['url'], + template_url=self.list_by_namespace.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_by_namespace_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -147,16 +164,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("EventHubListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -167,8 +182,8 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_namespace.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/eventhubs"} # type: ignore + list_by_namespace.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/eventhubs" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_migration_configs_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_migration_configs_operations.py index b08f30bed97b0..f1f4d87e3c810 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_migration_configs_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_migration_configs_operations.py @@ -6,11 +6,18 @@ # 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, Union, cast - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -22,251 +29,257 @@ 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') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +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, - namespace_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_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-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_and_start_migration_request_initial( +def build_create_and_start_migration_request( resource_group_name: str, namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], + config_name: Union[str, _models.MigrationConfigurationName], subscription_id: str, - *, - json: Optional[_models.MigrationConfigProperties] = None, - content: Any = 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', "2018-01-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: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "configName": _SERIALIZER.url("config_name", config_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "configName": _SERIALIZER.url("config_name", config_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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, - 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( resource_group_name: str, namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], + config_name: Union[str, _models.MigrationConfigurationName], 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-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "configName": _SERIALIZER.url("config_name", config_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "configName": _SERIALIZER.url("config_name", config_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( resource_group_name: str, namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], + config_name: Union[str, _models.MigrationConfigurationName], 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-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "configName": _SERIALIZER.url("config_name", config_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "configName": _SERIALIZER.url("config_name", config_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_complete_migration_request( resource_group_name: str, namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], + config_name: Union[str, _models.MigrationConfigurationName], 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-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/upgrade") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/upgrade", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "configName": _SERIALIZER.url("config_name", config_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "configName": _SERIALIZER.url("config_name", config_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_revert_request( resource_group_name: str, namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], + config_name: Union[str, _models.MigrationConfigurationName], 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-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/revert") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/revert", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "configName": _SERIALIZER.url("config_name", config_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "configName": _SERIALIZER.url("config_name", config_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + class MigrationConfigsOperations: """ @@ -287,65 +300,69 @@ def __init__(self, *args, **kwargs): 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, - namespace_name: str, - **kwargs: Any - ) -> Iterable[_models.MigrationConfigListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> Iterable["_models.MigrationConfigProperties"]: """Gets all migrationConfigurations. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MigrationConfigListResult or the result of + :return: An iterator like instance of either MigrationConfigProperties or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.MigrationConfigListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.MigrationConfigProperties] + :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', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MigrationConfigListResult] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[_models.MigrationConfigListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -353,16 +370,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("MigrationConfigListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -373,35 +388,46 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations" + } def _create_and_start_migration_initial( self, resource_group_name: str, namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], - parameters: _models.MigrationConfigProperties, + config_name: Union[str, _models.MigrationConfigurationName], + parameters: Union[_models.MigrationConfigProperties, IO], **kwargs: Any ) -> Optional[_models.MigrationConfigProperties]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.MigrationConfigProperties]] - - _json = self._serialize.body(parameters, 'MigrationConfigProperties') - - request = build_create_and_start_migration_request_initial( + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.MigrationConfigProperties]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "MigrationConfigProperties") + + request = build_create_and_start_migration_request( resource_group_name=resource_group_name, namespace_name=namespace_name, config_name=config_name, @@ -409,57 +435,146 @@ def _create_and_start_migration_initial( api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_and_start_migration_initial.metadata['url'], + content=_content, + template_url=self._create_and_start_migration_initial.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('MigrationConfigProperties', pipeline_response) + deserialized = self._deserialize("MigrationConfigProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_and_start_migration_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}"} # type: ignore + _create_and_start_migration_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}" + } + @overload + def begin_create_and_start_migration( + self, + resource_group_name: str, + namespace_name: str, + config_name: Union[str, _models.MigrationConfigurationName], + parameters: _models.MigrationConfigProperties, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.MigrationConfigProperties]: + """Creates Migration configuration and starts migration of entities from Standard to Premium + namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param config_name: The configuration name. Should always be "$default". "$default" Required. + :type config_name: str or + ~azure.mgmt.servicebus.v2018_01_01_preview.models.MigrationConfigurationName + :param parameters: Parameters required to create Migration Configuration. Required. + :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.MigrationConfigProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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 MigrationConfigProperties or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.servicebus.v2018_01_01_preview.models.MigrationConfigProperties] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_and_start_migration( + self, + resource_group_name: str, + namespace_name: str, + config_name: Union[str, _models.MigrationConfigurationName], + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.MigrationConfigProperties]: + """Creates Migration configuration and starts migration of entities from Standard to Premium + namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param config_name: The configuration name. Should always be "$default". "$default" Required. + :type config_name: str or + ~azure.mgmt.servicebus.v2018_01_01_preview.models.MigrationConfigurationName + :param parameters: Parameters required to create Migration Configuration. Required. + :type 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 + :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 MigrationConfigProperties or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.servicebus.v2018_01_01_preview.models.MigrationConfigProperties] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_and_start_migration( self, resource_group_name: str, namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], - parameters: _models.MigrationConfigProperties, + config_name: Union[str, _models.MigrationConfigurationName], + parameters: Union[_models.MigrationConfigProperties, IO], **kwargs: Any ) -> LROPoller[_models.MigrationConfigProperties]: """Creates Migration configuration and starts migration of entities from Standard to Premium namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :type config_name: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.MigrationConfigurationName - :param parameters: Parameters required to create Migration Configuration. + :param parameters: Parameters required to create Migration Configuration. Is either a model + type or a IO type. Required. :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.MigrationConfigProperties + 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 @@ -472,114 +587,114 @@ def begin_create_and_start_migration( of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.servicebus.v2018_01_01_preview.models.MigrationConfigProperties] - :raises: ~azure.core.exceptions.HttpResponseError + :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-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.MigrationConfigProperties] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.MigrationConfigProperties] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._create_and_start_migration_initial( # type: ignore + raw_result = self._create_and_start_migration_initial( resource_group_name=resource_group_name, namespace_name=namespace_name, config_name=config_name, parameters=parameters, 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): - deserialized = self._deserialize('MigrationConfigProperties', pipeline_response) + deserialized = self._deserialize("MigrationConfigProperties", 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 + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create_and_start_migration.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}"} # type: ignore + begin_create_and_start_migration.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}" + } @distributed_trace def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], + config_name: Union[str, _models.MigrationConfigurationName], **kwargs: Any ) -> None: """Deletes a MigrationConfiguration. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :type config_name: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.MigrationConfigurationName :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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, config_name=config_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -590,61 +705,65 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}"} # type: ignore - + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}" + } @distributed_trace def get( self, resource_group_name: str, namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], + config_name: Union[str, _models.MigrationConfigurationName], **kwargs: Any ) -> _models.MigrationConfigProperties: """Retrieves Migration Config. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :type config_name: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.MigrationConfigurationName :keyword callable cls: A custom type or function that will be passed the direct response - :return: MigrationConfigProperties, or the result of cls(response) + :return: MigrationConfigProperties or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.MigrationConfigProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MigrationConfigProperties] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[_models.MigrationConfigProperties] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, config_name=config_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -652,70 +771,74 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('MigrationConfigProperties', pipeline_response) + deserialized = self._deserialize("MigrationConfigProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}" + } @distributed_trace def complete_migration( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], + config_name: Union[str, _models.MigrationConfigurationName], **kwargs: Any ) -> None: """This operation Completes Migration of entities by pointing the connection strings to Premium namespace and any entities created after the operation will be under Premium Namespace. CompleteMigration operation will fail when entity migration is in-progress. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :type config_name: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.MigrationConfigurationName :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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_complete_migration_request( resource_group_name=resource_group_name, namespace_name=namespace_name, config_name=config_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.complete_migration.metadata['url'], + template_url=self.complete_migration.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -726,61 +849,65 @@ def complete_migration( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - complete_migration.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/upgrade"} # type: ignore - + complete_migration.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/upgrade" + } @distributed_trace def revert( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], + config_name: Union[str, _models.MigrationConfigurationName], **kwargs: Any ) -> None: """This operation reverts Migration. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :type config_name: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.MigrationConfigurationName :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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_revert_request( resource_group_name=resource_group_name, namespace_name=namespace_name, config_name=config_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.revert.metadata['url'], + template_url=self.revert.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -791,5 +918,6 @@ def revert( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - revert.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/revert"} # type: ignore - + revert.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/revert" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_namespaces_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_namespaces_operations.py index 8cbcfe7bede72..c5c14daf1c934 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_namespaces_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_namespaces_operations.py @@ -6,11 +6,18 @@ # 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, Union, cast - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -22,1020 +29,929 @@ 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') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_ip_filter_rules_request( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_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-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/ipfilterrules") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/ipfilterrules", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_ip_filter_rule_request( - resource_group_name: str, - namespace_name: str, - ip_filter_rule_name: str, - subscription_id: str, - *, - json: Optional[_models.IpFilterRule] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_name: str, ip_filter_rule_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-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: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/ipfilterrules/{ipFilterRuleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/ipfilterrules/{ipFilterRuleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "ipFilterRuleName": _SERIALIZER.url("ip_filter_rule_name", ip_filter_rule_name, 'str', min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "ipFilterRuleName": _SERIALIZER.url("ip_filter_rule_name", ip_filter_rule_name, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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, - 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_ip_filter_rule_request( - resource_group_name: str, - namespace_name: str, - ip_filter_rule_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, ip_filter_rule_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-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/ipfilterrules/{ipFilterRuleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/ipfilterrules/{ipFilterRuleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "ipFilterRuleName": _SERIALIZER.url("ip_filter_rule_name", ip_filter_rule_name, 'str', min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "ipFilterRuleName": _SERIALIZER.url("ip_filter_rule_name", ip_filter_rule_name, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_ip_filter_rule_request( - resource_group_name: str, - namespace_name: str, - ip_filter_rule_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, ip_filter_rule_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-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/ipfilterrules/{ipFilterRuleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/ipfilterrules/{ipFilterRuleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "ipFilterRuleName": _SERIALIZER.url("ip_filter_rule_name", ip_filter_rule_name, 'str', min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "ipFilterRuleName": _SERIALIZER.url("ip_filter_rule_name", ip_filter_rule_name, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_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-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/namespaces") 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: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _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: + +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-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _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( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - *, - json: Optional[_models.SBNamespace] = None, - content: Any = None, - **kwargs: Any +def build_create_or_update_request( + resource_group_name: str, namespace_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-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: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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, - 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( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - **kwargs: Any + +def build_delete_request( + resource_group_name: str, namespace_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-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_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-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _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, - namespace_name: str, - subscription_id: str, - *, - json: Optional[_models.SBNamespaceUpdateParameters] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_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-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: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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, - 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_list_virtual_network_rules_request( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_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-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/virtualnetworkrules") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/virtualnetworkrules", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_virtual_network_rule_request( - resource_group_name: str, - namespace_name: str, - virtual_network_rule_name: str, - subscription_id: str, - *, - json: Optional[_models.VirtualNetworkRule] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_name: str, virtual_network_rule_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-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: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/virtualnetworkrules/{virtualNetworkRuleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/virtualnetworkrules/{virtualNetworkRuleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "virtualNetworkRuleName": _SERIALIZER.url("virtual_network_rule_name", virtual_network_rule_name, 'str', min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "virtualNetworkRuleName": _SERIALIZER.url( + "virtual_network_rule_name", virtual_network_rule_name, "str", min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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, - 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_virtual_network_rule_request( - resource_group_name: str, - namespace_name: str, - virtual_network_rule_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, virtual_network_rule_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-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/virtualnetworkrules/{virtualNetworkRuleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/virtualnetworkrules/{virtualNetworkRuleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "virtualNetworkRuleName": _SERIALIZER.url("virtual_network_rule_name", virtual_network_rule_name, 'str', min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "virtualNetworkRuleName": _SERIALIZER.url( + "virtual_network_rule_name", virtual_network_rule_name, "str", min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_virtual_network_rule_request( - resource_group_name: str, - namespace_name: str, - virtual_network_rule_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, virtual_network_rule_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-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/virtualnetworkrules/{virtualNetworkRuleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/virtualnetworkrules/{virtualNetworkRuleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "virtualNetworkRuleName": _SERIALIZER.url("virtual_network_rule_name", virtual_network_rule_name, 'str', min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "virtualNetworkRuleName": _SERIALIZER.url( + "virtual_network_rule_name", virtual_network_rule_name, "str", min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_authorization_rules_request( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_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-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_authorization_rule_request( - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - subscription_id: str, - *, - json: Optional[_models.SBAuthorizationRule] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_name: str, authorization_rule_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-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: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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, - 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_authorization_rule_request( - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, authorization_rule_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-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_authorization_rule_request( - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, authorization_rule_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-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_keys_request( - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, authorization_rule_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-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/listKeys") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/listKeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_regenerate_keys_request( - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - subscription_id: str, - *, - json: Optional[_models.RegenerateAccessKeyParameters] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_name: str, authorization_rule_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-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: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/regenerateKeys") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/regenerateKeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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, - 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_check_name_availability_request( - subscription_id: str, - *, - json: Optional[_models.CheckNameAvailability] = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: + +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-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: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/CheckNameAvailability") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/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: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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, - 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_create_or_update_network_rule_set_request( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - *, - json: Optional[_models.NetworkRuleSet] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_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-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: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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, - 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_get_network_rule_set_request( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_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-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_network_rule_sets_request( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_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-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_migrate_request( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - *, - json: Optional[_models.SBNamespaceMigrate] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_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-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: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrate", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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, - 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 NamespacesOperations: # pylint: disable=too-many-public-methods """ @@ -1056,65 +972,68 @@ def __init__(self, *args, **kwargs): 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_ip_filter_rules( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> Iterable[_models.IpFilterRuleListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> Iterable["_models.IpFilterRule"]: """Gets a list of IP Filter rules for a Namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IpFilterRuleListResult or the result of - cls(response) + :return: An iterator like instance of either IpFilterRule or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.IpFilterRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.IpFilterRule] + :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', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.IpFilterRuleListResult] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[_models.IpFilterRuleListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_ip_filter_rules_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_ip_filter_rules.metadata['url'], + template_url=self.list_ip_filter_rules.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_ip_filter_rules_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -1122,16 +1041,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("IpFilterRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1142,49 +1059,123 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_ip_filter_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/ipfilterrules"} # type: ignore + list_ip_filter_rules.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/ipfilterrules" + } - @distributed_trace + @overload def create_or_update_ip_filter_rule( self, resource_group_name: str, namespace_name: str, ip_filter_rule_name: str, parameters: _models.IpFilterRule, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.IpFilterRule: """Creates or updates an IpFilterRule for a Namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param ip_filter_rule_name: The IP Filter Rule name. + :param ip_filter_rule_name: The IP Filter Rule name. Required. :type ip_filter_rule_name: str - :param parameters: The Namespace IpFilterRule. + :param parameters: The Namespace IpFilterRule. Required. :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.IpFilterRule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IpFilterRule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.IpFilterRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_ip_filter_rule( + self, + resource_group_name: str, + namespace_name: str, + ip_filter_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.IpFilterRule: + """Creates or updates an IpFilterRule for a Namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param ip_filter_rule_name: The IP Filter Rule name. Required. + :type ip_filter_rule_name: str + :param parameters: The Namespace IpFilterRule. Required. + :type 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: IpFilterRule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.IpFilterRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update_ip_filter_rule( + self, + resource_group_name: str, + namespace_name: str, + ip_filter_rule_name: str, + parameters: Union[_models.IpFilterRule, IO], + **kwargs: Any + ) -> _models.IpFilterRule: + """Creates or updates an IpFilterRule for a Namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param ip_filter_rule_name: The IP Filter Rule name. Required. + :type ip_filter_rule_name: str + :param parameters: The Namespace IpFilterRule. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.IpFilterRule 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: IpFilterRule, or the result of cls(response) + :return: IpFilterRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.IpFilterRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.IpFilterRule] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.IpFilterRule] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'IpFilterRule') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "IpFilterRule") request = build_create_or_update_ip_filter_rule_request( resource_group_name=resource_group_name, @@ -1194,18 +1185,18 @@ def create_or_update_ip_filter_rule( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_ip_filter_rule.metadata['url'], + content=_content, + template_url=self.create_or_update_ip_filter_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1213,67 +1204,67 @@ def create_or_update_ip_filter_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('IpFilterRule', pipeline_response) + deserialized = self._deserialize("IpFilterRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_ip_filter_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/ipfilterrules/{ipFilterRuleName}"} # type: ignore - + create_or_update_ip_filter_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/ipfilterrules/{ipFilterRuleName}" + } @distributed_trace def delete_ip_filter_rule( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - ip_filter_rule_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, ip_filter_rule_name: str, **kwargs: Any ) -> None: """Deletes an IpFilterRule for a Namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param ip_filter_rule_name: The IP Filter Rule name. + :param ip_filter_rule_name: The IP Filter Rule name. Required. :type ip_filter_rule_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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_ip_filter_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, ip_filter_rule_name=ip_filter_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_ip_filter_rule.metadata['url'], + template_url=self.delete_ip_filter_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1284,60 +1275,60 @@ def delete_ip_filter_rule( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete_ip_filter_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/ipfilterrules/{ipFilterRuleName}"} # type: ignore - + delete_ip_filter_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/ipfilterrules/{ipFilterRuleName}" + } @distributed_trace def get_ip_filter_rule( - self, - resource_group_name: str, - namespace_name: str, - ip_filter_rule_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, ip_filter_rule_name: str, **kwargs: Any ) -> _models.IpFilterRule: """Gets an IpFilterRule for a Namespace by rule name. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param ip_filter_rule_name: The IP Filter Rule name. + :param ip_filter_rule_name: The IP Filter Rule name. Required. :type ip_filter_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: IpFilterRule, or the result of cls(response) + :return: IpFilterRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.IpFilterRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.IpFilterRule] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[_models.IpFilterRule] = kwargs.pop("cls", None) - request = build_get_ip_filter_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, ip_filter_rule_name=ip_filter_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_ip_filter_rule.metadata['url'], + template_url=self.get_ip_filter_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1345,64 +1336,71 @@ def get_ip_filter_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('IpFilterRule', pipeline_response) + deserialized = self._deserialize("IpFilterRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_ip_filter_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/ipfilterrules/{ipFilterRuleName}"} # type: ignore - + get_ip_filter_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/ipfilterrules/{ipFilterRuleName}" + } @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable[_models.SBNamespaceListResult]: + def list(self, **kwargs: Any) -> Iterable["_models.SBNamespace"]: """Gets all the available namespaces within the subscription, irrespective of the resource groups. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBNamespaceListResult or the result of - cls(response) + :return: An iterator like instance of either SBNamespace or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBNamespaceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBNamespace] + :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', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBNamespaceListResult] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[_models.SBNamespaceListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -1410,16 +1408,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("SBNamespaceListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1430,65 +1426,67 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/namespaces"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/namespaces"} @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable[_models.SBNamespaceListResult]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.SBNamespace"]: """Gets the available namespaces within a resource group. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. 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 SBNamespaceListResult or the result of - cls(response) + :return: An iterator like instance of either SBNamespace or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBNamespaceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBNamespace] + :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', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBNamespaceListResult] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[_models.SBNamespaceListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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'], + 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 + request.url = self._client.format_url(request.url) else: - - 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=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -1496,16 +1494,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("SBNamespaceListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1516,90 +1512,173 @@ 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.ServiceBus/namespaces"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces" + } def _create_or_update_initial( - self, - resource_group_name: str, - namespace_name: str, - parameters: _models.SBNamespace, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, parameters: Union[_models.SBNamespace, IO], **kwargs: Any ) -> Optional[_models.SBNamespace]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.SBNamespace]] - - _json = self._serialize.body(parameters, 'SBNamespace') - - request = build_create_or_update_request_initial( + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.SBNamespace]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBNamespace") + + request = build_create_or_update_request( resource_group_name=resource_group_name, namespace_name=namespace_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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('SBNamespace', pipeline_response) + deserialized = self._deserialize("SBNamespace", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('SBNamespace', pipeline_response) + deserialized = self._deserialize("SBNamespace", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore - + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}" + } - @distributed_trace + @overload def begin_create_or_update( self, resource_group_name: str, namespace_name: str, parameters: _models.SBNamespace, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.SBNamespace]: """Creates or updates a service namespace. Once created, this namespace's resource manifest is immutable. This operation is idempotent. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: Parameters supplied to create a namespace resource. + :param parameters: Parameters supplied to create a namespace resource. Required. :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBNamespace + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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 SBNamespace or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBNamespace] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.SBNamespace]: + """Creates or updates a service namespace. Once created, this namespace's resource manifest is + immutable. This operation is idempotent. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to create a namespace resource. Required. + :type 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 + :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 SBNamespace or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBNamespace] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, resource_group_name: str, namespace_name: str, parameters: Union[_models.SBNamespace, IO], **kwargs: Any + ) -> LROPoller[_models.SBNamespace]: + """Creates or updates a service namespace. Once created, this namespace's resource manifest is + immutable. This operation is idempotent. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to create a namespace resource. Is either a model type + or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBNamespace 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 @@ -1612,121 +1691,115 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBNamespace] - :raises: ~azure.core.exceptions.HttpResponseError + :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-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBNamespace] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SBNamespace] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._create_or_update_initial( # type: ignore + raw_result = self._create_or_update_initial( resource_group_name=resource_group_name, namespace_name=namespace_name, parameters=parameters, 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): - deserialized = self._deserialize('SBNamespace', pipeline_response) + deserialized = self._deserialize("SBNamespace", 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 + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}" + } def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, **kwargs: Any ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request_initial( + request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + 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 + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}" + } @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete(self, resource_group_name: str, namespace_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes an existing namespace. This operation also removes all associated resources under the namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_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. @@ -1738,103 +1811,98 @@ def begin_delete( # pylint: disable=inconsistent-return-statements 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: """ _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-01-preview")) # type: 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 + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, namespace_name=namespace_name, api_version=api_version, - 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 = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}" + } @distributed_trace - def get( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> _models.SBNamespace: + def get(self, resource_group_name: str, namespace_name: str, **kwargs: Any) -> _models.SBNamespace: """Gets a description for the specified namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBNamespace, or the result of cls(response) + :return: SBNamespace or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBNamespace - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBNamespace] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[_models.SBNamespace] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1842,51 +1910,124 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBNamespace', pipeline_response) + deserialized = self._deserialize("SBNamespace", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}" + } + + @overload + def update( + self, + resource_group_name: str, + namespace_name: str, + parameters: _models.SBNamespaceUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> Optional[_models.SBNamespace]: + """Updates a service namespace. Once created, this namespace's resource manifest is immutable. + This operation is idempotent. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to update a namespace resource. Required. + :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBNamespaceUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBNamespace or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBNamespace or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> Optional[_models.SBNamespace]: + """Updates a service namespace. Once created, this namespace's resource manifest is immutable. + This operation is idempotent. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to update a namespace resource. Required. + :type 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: SBNamespace or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBNamespace or None + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def update( self, resource_group_name: str, namespace_name: str, - parameters: _models.SBNamespaceUpdateParameters, + parameters: Union[_models.SBNamespaceUpdateParameters, IO], **kwargs: Any ) -> Optional[_models.SBNamespace]: """Updates a service namespace. Once created, this namespace's resource manifest is immutable. This operation is idempotent. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: Parameters supplied to update a namespace resource. + :param parameters: Parameters supplied to update a namespace resource. Is either a model type + or a IO type. Required. :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBNamespaceUpdateParameters + 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: SBNamespace, or the result of cls(response) + :return: SBNamespace or None or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBNamespace or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.SBNamespace]] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.SBNamespace]] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'SBNamespaceUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBNamespaceUpdateParameters") request = build_update_request( resource_group_name=resource_group_name, @@ -1895,18 +2036,18 @@ def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -1916,77 +2057,82 @@ def update( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('SBNamespace', pipeline_response) + deserialized = self._deserialize("SBNamespace", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('SBNamespace', pipeline_response) + deserialized = self._deserialize("SBNamespace", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore - + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}" + } @distributed_trace def list_virtual_network_rules( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> Iterable[_models.VirtualNetworkRuleListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> Iterable["_models.VirtualNetworkRule"]: """Gets a list of VirtualNetwork rules for a Namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either VirtualNetworkRuleListResult or the result of - cls(response) + :return: An iterator like instance of either VirtualNetworkRule or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.VirtualNetworkRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.VirtualNetworkRule] + :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', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualNetworkRuleListResult] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[_models.VirtualNetworkRuleListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_virtual_network_rules_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_virtual_network_rules.metadata['url'], + template_url=self.list_virtual_network_rules.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_virtual_network_rules_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -1994,16 +2140,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("VirtualNetworkRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2014,49 +2158,124 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_virtual_network_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/virtualnetworkrules"} # type: ignore + list_virtual_network_rules.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/virtualnetworkrules" + } - @distributed_trace + @overload def create_or_update_virtual_network_rule( self, resource_group_name: str, namespace_name: str, virtual_network_rule_name: str, parameters: _models.VirtualNetworkRule, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.VirtualNetworkRule: """Creates or updates an VirtualNetworkRule for a Namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param virtual_network_rule_name: The Virtual Network Rule name. + :param virtual_network_rule_name: The Virtual Network Rule name. Required. :type virtual_network_rule_name: str - :param parameters: The Namespace VirtualNetworkRule. + :param parameters: The Namespace VirtualNetworkRule. Required. :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.VirtualNetworkRule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: VirtualNetworkRule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.VirtualNetworkRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_virtual_network_rule( + self, + resource_group_name: str, + namespace_name: str, + virtual_network_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.VirtualNetworkRule: + """Creates or updates an VirtualNetworkRule for a Namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param virtual_network_rule_name: The Virtual Network Rule name. Required. + :type virtual_network_rule_name: str + :param parameters: The Namespace VirtualNetworkRule. Required. + :type 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: VirtualNetworkRule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.VirtualNetworkRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update_virtual_network_rule( + self, + resource_group_name: str, + namespace_name: str, + virtual_network_rule_name: str, + parameters: Union[_models.VirtualNetworkRule, IO], + **kwargs: Any + ) -> _models.VirtualNetworkRule: + """Creates or updates an VirtualNetworkRule for a Namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param virtual_network_rule_name: The Virtual Network Rule name. Required. + :type virtual_network_rule_name: str + :param parameters: The Namespace VirtualNetworkRule. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.VirtualNetworkRule 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: VirtualNetworkRule, or the result of cls(response) + :return: VirtualNetworkRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.VirtualNetworkRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualNetworkRule] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.VirtualNetworkRule] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'VirtualNetworkRule') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "VirtualNetworkRule") request = build_create_or_update_virtual_network_rule_request( resource_group_name=resource_group_name, @@ -2066,18 +2285,18 @@ def create_or_update_virtual_network_rule( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_virtual_network_rule.metadata['url'], + content=_content, + template_url=self.create_or_update_virtual_network_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -2085,67 +2304,67 @@ def create_or_update_virtual_network_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('VirtualNetworkRule', pipeline_response) + deserialized = self._deserialize("VirtualNetworkRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_virtual_network_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/virtualnetworkrules/{virtualNetworkRuleName}"} # type: ignore - + create_or_update_virtual_network_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/virtualnetworkrules/{virtualNetworkRuleName}" + } @distributed_trace def delete_virtual_network_rule( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - virtual_network_rule_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, virtual_network_rule_name: str, **kwargs: Any ) -> None: """Deletes an VirtualNetworkRule for a Namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param virtual_network_rule_name: The Virtual Network Rule name. + :param virtual_network_rule_name: The Virtual Network Rule name. Required. :type virtual_network_rule_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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_virtual_network_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, virtual_network_rule_name=virtual_network_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_virtual_network_rule.metadata['url'], + template_url=self.delete_virtual_network_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -2156,60 +2375,60 @@ def delete_virtual_network_rule( # pylint: disable=inconsistent-return-statemen if cls: return cls(pipeline_response, None, {}) - delete_virtual_network_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/virtualnetworkrules/{virtualNetworkRuleName}"} # type: ignore - + delete_virtual_network_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/virtualnetworkrules/{virtualNetworkRuleName}" + } @distributed_trace def get_virtual_network_rule( - self, - resource_group_name: str, - namespace_name: str, - virtual_network_rule_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, virtual_network_rule_name: str, **kwargs: Any ) -> _models.VirtualNetworkRule: """Gets an VirtualNetworkRule for a Namespace by rule name. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param virtual_network_rule_name: The Virtual Network Rule name. + :param virtual_network_rule_name: The Virtual Network Rule name. Required. :type virtual_network_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: VirtualNetworkRule, or the result of cls(response) + :return: VirtualNetworkRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.VirtualNetworkRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualNetworkRule] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[_models.VirtualNetworkRule] = kwargs.pop("cls", None) - request = build_get_virtual_network_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, virtual_network_rule_name=virtual_network_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_virtual_network_rule.metadata['url'], + template_url=self.get_virtual_network_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -2217,74 +2436,79 @@ def get_virtual_network_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('VirtualNetworkRule', pipeline_response) + deserialized = self._deserialize("VirtualNetworkRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_virtual_network_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/virtualnetworkrules/{virtualNetworkRuleName}"} # type: ignore - + get_virtual_network_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/virtualnetworkrules/{virtualNetworkRuleName}" + } @distributed_trace def list_authorization_rules( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> Iterable[_models.SBAuthorizationRuleListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> Iterable["_models.SBAuthorizationRule"]: """Gets the authorization rules for a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of - cls(response) + :return: An iterator like instance of either SBAuthorizationRule or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRule] + :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', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRuleListResult] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[_models.SBAuthorizationRuleListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_authorization_rules_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_authorization_rules.metadata['url'], + template_url=self.list_authorization_rules.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_authorization_rules_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -2292,16 +2516,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("SBAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2312,49 +2534,124 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_authorization_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules"} # type: ignore + list_authorization_rules.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules" + } - @distributed_trace + @overload def create_or_update_authorization_rule( self, resource_group_name: str, namespace_name: str, authorization_rule_name: str, parameters: _models.SBAuthorizationRule, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SBAuthorizationRule: """Creates or updates an authorization rule for a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: The shared access authorization rule. + :param parameters: The shared access authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBAuthorizationRule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates or updates an authorization rule for a namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Required. + :type 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: SBAuthorizationRule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: Union[_models.SBAuthorizationRule, IO], + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates or updates an authorization rule for a namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRule 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: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SBAuthorizationRule] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'SBAuthorizationRule') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBAuthorizationRule") request = build_create_or_update_authorization_rule_request( resource_group_name=resource_group_name, @@ -2364,18 +2661,18 @@ def create_or_update_authorization_rule( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_authorization_rule.metadata['url'], + content=_content, + template_url=self.create_or_update_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -2383,67 +2680,67 @@ def create_or_update_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}"} # type: ignore - + create_or_update_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}" + } @distributed_trace def delete_authorization_rule( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, authorization_rule_name: str, **kwargs: Any ) -> None: """Deletes a namespace authorization rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_authorization_rule.metadata['url'], + template_url=self.delete_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -2454,60 +2751,60 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}"} # type: ignore - + delete_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}" + } @distributed_trace def get_authorization_rule( - self, - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, authorization_rule_name: str, **kwargs: Any ) -> _models.SBAuthorizationRule: """Gets an authorization rule for a namespace by rule name. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[_models.SBAuthorizationRule] = kwargs.pop("cls", None) - request = build_get_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_authorization_rule.metadata['url'], + template_url=self.get_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -2515,67 +2812,67 @@ def get_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}"} # type: ignore - + get_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}" + } @distributed_trace def list_keys( - self, - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, authorization_rule_name: str, **kwargs: Any ) -> _models.AccessKeys: """Gets the primary and secondary connection strings for the namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[_models.AccessKeys] = kwargs.pop("cls", None) - request = build_list_keys_request( resource_group_name=resource_group_name, namespace_name=namespace_name, authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata['url'], + 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 + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -2583,54 +2880,131 @@ def list_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + deserialized = self._deserialize("AccessKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/listKeys"} # type: ignore - + list_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/listKeys" + } - @distributed_trace + @overload def regenerate_keys( self, resource_group_name: str, namespace_name: str, authorization_rule_name: str, parameters: _models.RegenerateAccessKeyParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.AccessKeys: """Regenerates the primary or secondary connection strings for the namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate the authorization rule. + :param parameters: Parameters supplied to regenerate the authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.RegenerateAccessKeyParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AccessKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AccessKeys: + """Regenerates the primary or secondary connection strings for the namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Required. + :type 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: AccessKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: Union[_models.RegenerateAccessKeyParameters, IO], + **kwargs: Any + ) -> _models.AccessKeys: + """Regenerates the primary or secondary connection strings for the namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Is either a model + type or a IO type. Required. + :type parameters: + ~azure.mgmt.servicebus.v2018_01_01_preview.models.RegenerateAccessKeyParameters 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: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AccessKeys] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RegenerateAccessKeyParameters") request = build_regenerate_keys_request( resource_group_name=resource_group_name, @@ -2640,18 +3014,18 @@ def regenerate_keys( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_keys.metadata['url'], + content=_content, + template_url=self.regenerate_keys.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -2659,62 +3033,110 @@ def regenerate_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + deserialized = self._deserialize("AccessKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/regenerateKeys"} # type: ignore + regenerate_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/regenerateKeys" + } + @overload + def check_name_availability( + self, parameters: _models.CheckNameAvailability, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param parameters: Parameters to check availability of the given namespace name. Required. + :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.CheckNameAvailability + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckNameAvailabilityResult or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param parameters: Parameters to check availability of the given namespace name. Required. + :type 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: CheckNameAvailabilityResult or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def check_name_availability( - self, - parameters: _models.CheckNameAvailability, - **kwargs: Any + self, parameters: Union[_models.CheckNameAvailability, IO], **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Check the give namespace name availability. - :param parameters: Parameters to check availability of the given namespace name. - :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.CheckNameAvailability + :param parameters: Parameters to check availability of the given namespace name. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.CheckNameAvailability 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: CheckNameAvailabilityResult, or the result of cls(response) + :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.CheckNameAvailabilityResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.CheckNameAvailabilityResult] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CheckNameAvailabilityResult] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'CheckNameAvailability') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "CheckNameAvailability") 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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -2722,50 +3144,119 @@ def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) + deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/CheckNameAvailability"} # type: ignore - + check_name_availability.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/CheckNameAvailability" + } - @distributed_trace + @overload def create_or_update_network_rule_set( self, resource_group_name: str, namespace_name: str, parameters: _models.NetworkRuleSet, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.NetworkRuleSet: """Create or update NetworkRuleSet for a Namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: The Namespace IpFilterRule. + :param parameters: The Namespace IpFilterRule. Required. :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.NetworkRuleSet + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: NetworkRuleSet, or the result of cls(response) + :return: NetworkRuleSet or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.NetworkRuleSet - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_network_rule_set( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.NetworkRuleSet: + """Create or update NetworkRuleSet for a Namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: The Namespace IpFilterRule. Required. + :type 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: NetworkRuleSet or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.NetworkRuleSet + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update_network_rule_set( + self, + resource_group_name: str, + namespace_name: str, + parameters: Union[_models.NetworkRuleSet, IO], + **kwargs: Any + ) -> _models.NetworkRuleSet: + """Create or update NetworkRuleSet for a Namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: The Namespace IpFilterRule. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.NetworkRuleSet 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: NetworkRuleSet or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.NetworkRuleSet + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.NetworkRuleSet] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.NetworkRuleSet] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'NetworkRuleSet') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "NetworkRuleSet") request = build_create_or_update_network_rule_set_request( resource_group_name=resource_group_name, @@ -2774,18 +3265,18 @@ def create_or_update_network_rule_set( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_network_rule_set.metadata['url'], + content=_content, + template_url=self.create_or_update_network_rule_set.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -2793,63 +3284,64 @@ def create_or_update_network_rule_set( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('NetworkRuleSet', pipeline_response) + deserialized = self._deserialize("NetworkRuleSet", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_network_rule_set.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default"} # type: ignore - + create_or_update_network_rule_set.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default" + } @distributed_trace def get_network_rule_set( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, **kwargs: Any ) -> _models.NetworkRuleSet: """Gets NetworkRuleSet for a Namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: NetworkRuleSet, or the result of cls(response) + :return: NetworkRuleSet or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.NetworkRuleSet - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.NetworkRuleSet] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[_models.NetworkRuleSet] = kwargs.pop("cls", None) - request = build_get_network_rule_set_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_network_rule_set.metadata['url'], + template_url=self.get_network_rule_set.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -2857,74 +3349,79 @@ def get_network_rule_set( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('NetworkRuleSet', pipeline_response) + deserialized = self._deserialize("NetworkRuleSet", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_network_rule_set.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default"} # type: ignore - + get_network_rule_set.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default" + } @distributed_trace def list_network_rule_sets( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> Iterable[_models.NetworkRuleSetListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> Iterable["_models.NetworkRuleSet"]: """Gets list of NetworkRuleSet for a Namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either NetworkRuleSetListResult or the result of - cls(response) + :return: An iterator like instance of either NetworkRuleSet or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.NetworkRuleSetListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.NetworkRuleSet] + :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', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.NetworkRuleSetListResult] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[_models.NetworkRuleSetListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_network_rule_sets_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_network_rule_sets.metadata['url'], + template_url=self.list_network_rule_sets.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_network_rule_sets_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -2932,16 +3429,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("NetworkRuleSetListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2952,46 +3447,115 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_network_rule_sets.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets"} # type: ignore + list_network_rule_sets.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets" + } - @distributed_trace + @overload def migrate( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, parameters: _models.SBNamespaceMigrate, + *, + content_type: str = "application/json", **kwargs: Any ) -> None: """This operation Migrate the given namespace to provided name type. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: Parameters supplied to migrate namespace type. + :param parameters: Parameters supplied to migrate namespace type. Required. :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBNamespaceMigrate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default 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: + """ + + @overload + def migrate( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """This operation Migrate the given namespace to provided name type. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to migrate namespace type. Required. + :type 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: 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: + """ + + @distributed_trace + def migrate( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + namespace_name: str, + parameters: Union[_models.SBNamespaceMigrate, IO], + **kwargs: Any + ) -> None: + """This operation Migrate the given namespace to provided name type. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to migrate namespace type. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBNamespaceMigrate 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: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'SBNamespaceMigrate') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBNamespaceMigrate") request = build_migrate_request( resource_group_name=resource_group_name, @@ -3000,18 +3564,18 @@ def migrate( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, json=_json, - template_url=self.migrate.metadata['url'], + content=_content, + template_url=self.migrate.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -3022,5 +3586,6 @@ def migrate( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - migrate.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrate"} # type: ignore - + migrate.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrate" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_operations.py index 17015193e6032..dc34e51fcab1b 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_operations.py @@ -6,11 +6,18 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,38 +27,40 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +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: + +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-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.ServiceBus/operations") # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + class Operations: """ @@ -72,52 +81,59 @@ def __init__(self, *args, **kwargs): 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 ServiceBus 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.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_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', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_request( - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -125,16 +141,14 @@ 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) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -145,8 +159,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.ServiceBus/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.ServiceBus/operations"} diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_patch.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_patch.py index 0ad201a8c586e..f7dd32510333d 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_patch.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_premium_messaging_regions_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_premium_messaging_regions_operations.py index a5f3e7668937b..34c6d1e7e243a 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_premium_messaging_regions_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_premium_messaging_regions_operations.py @@ -6,11 +6,18 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,44 +27,47 @@ 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') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +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, - **kwargs: Any -) -> HttpRequest: + +def build_list_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-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/premiumMessagingRegions") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/premiumMessagingRegions" + ) # pylint: disable=line-too-long 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: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + class PremiumMessagingRegionsOperations: """ @@ -78,55 +88,61 @@ def __init__(self, *args, **kwargs): 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.PremiumMessagingRegionsListResult]: + def list(self, **kwargs: Any) -> Iterable["_models.PremiumMessagingRegions"]: """Gets the available premium messaging regions for servicebus. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PremiumMessagingRegionsListResult or the result of + :return: An iterator like instance of either PremiumMessagingRegions or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.PremiumMessagingRegionsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.PremiumMessagingRegions] + :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', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PremiumMessagingRegionsListResult] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[_models.PremiumMessagingRegionsListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -134,16 +150,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("PremiumMessagingRegionsListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -154,8 +168,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': "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/premiumMessagingRegions"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/premiumMessagingRegions"} diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_private_endpoint_connections_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_private_endpoint_connections_operations.py index f159fa5afd311..0b5a1e383eced 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_private_endpoint_connections_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_private_endpoint_connections_operations.py @@ -6,11 +6,18 @@ # 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, Union, cast - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -22,134 +29,140 @@ 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') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +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, - namespace_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_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-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( - subscription_id: str, resource_group_name: str, namespace_name: str, private_endpoint_connection_name: str, - *, - json: Optional[_models.PrivateEndpointConnection] = None, - content: Any = None, + 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-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: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/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', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "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", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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, - 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( + +def build_delete_request( resource_group_name: str, namespace_name: str, - subscription_id: 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', "2018-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( @@ -162,33 +175,37 @@ def build_get_request( _headers = case_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-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "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", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + class PrivateEndpointConnectionsOperations: """ @@ -209,65 +226,69 @@ def __init__(self, *args, **kwargs): 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, - namespace_name: str, - **kwargs: Any - ) -> Iterable[_models.PrivateEndpointConnectionListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> Iterable["_models.PrivateEndpointConnection"]: """Gets the available PrivateEndpointConnections within a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateEndpointConnectionListResult or the result - of cls(response) + :return: An iterator like instance of either PrivateEndpointConnection or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.PrivateEndpointConnectionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_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', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnectionListResult] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -275,16 +296,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -295,71 +314,148 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections" + } - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, namespace_name: str, private_endpoint_connection_name: str, parameters: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.PrivateEndpointConnection: """Creates or updates PrivateEndpointConnections of service namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param private_endpoint_connection_name: The PrivateEndpointConnection name. + :param private_endpoint_connection_name: The PrivateEndpointConnection name. Required. :type private_endpoint_connection_name: str :param parameters: Parameters supplied to update Status of PrivateEndPoint Connection to - namespace resource. + namespace resource. Required. :type parameters: ~azure.mgmt.servicebus.v2018_01_01_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 - :return: PrivateEndpointConnection, or the result of cls(response) + :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + private_endpoint_connection_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Creates or updates PrivateEndpointConnections of service namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param private_endpoint_connection_name: The PrivateEndpointConnection name. Required. + :type private_endpoint_connection_name: str + :param parameters: Parameters supplied to update Status of PrivateEndPoint Connection to + namespace resource. Required. + :type 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: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + private_endpoint_connection_name: str, + parameters: Union[_models.PrivateEndpointConnection, IO], + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Creates or updates PrivateEndpointConnections of service namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param private_endpoint_connection_name: The PrivateEndpointConnection name. Required. + :type private_endpoint_connection_name: str + :param parameters: Parameters supplied to update Status of PrivateEndPoint Connection to + namespace resource. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2018_01_01_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 + :return: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'PrivateEndpointConnection') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PrivateEndpointConnection") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, namespace_name=namespace_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.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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -368,83 +464,81 @@ def create_or_update( 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 cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + return deserialized # type: ignore + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}" + } def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request_initial( + request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, - subscription_id=self._config.subscription_id, 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'], + 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 + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}" + } @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, namespace_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes an existing Private Endpoint Connection. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param private_endpoint_connection_name: The PrivateEndpointConnection name. + :param private_endpoint_connection_name: The PrivateEndpointConnection name. 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. @@ -456,108 +550,104 @@ def begin_delete( # pylint: disable=inconsistent-return-statements 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: """ _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-01-preview")) # type: 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 + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, namespace_name=namespace_name, private_endpoint_connection_name=private_endpoint_connection_name, api_version=api_version, - 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 = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}" + } @distributed_trace def get( - self, - resource_group_name: str, - namespace_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> _models.PrivateEndpointConnection: """Gets a description for the specified Private Endpoint Connection. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param private_endpoint_connection_name: The PrivateEndpointConnection name. + :param private_endpoint_connection_name: The PrivateEndpointConnection name. 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.servicebus.v2018_01_01_preview.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_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'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -565,12 +655,13 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, 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.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_private_link_resources_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_private_link_resources_operations.py index d1ab1a13f50e0..43c1272e5f108 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_private_link_resources_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_private_link_resources_operations.py @@ -6,11 +6,17 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Optional, TypeVar -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest @@ -19,48 +25,54 @@ 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') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +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, - namespace_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_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-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateLinkResources") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateLinkResources", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + class PrivateLinkResourcesOperations: """ @@ -81,54 +93,53 @@ def __init__(self, *args, **kwargs): 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, - namespace_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, **kwargs: Any ) -> _models.PrivateLinkResourcesListResult: """Gets lists of resources that supports Privatelinks. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateLinkResourcesListResult, or the result of cls(response) + :return: PrivateLinkResourcesListResult or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.PrivateLinkResourcesListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateLinkResourcesListResult] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[_models.PrivateLinkResourcesListResult] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -136,12 +147,13 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateLinkResourcesListResult', pipeline_response) + deserialized = self._deserialize("PrivateLinkResourcesListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateLinkResources"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateLinkResources" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_queues_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_queues_operations.py index 38a618ede0a4f..9bfbd10f05e73 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_queues_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_queues_operations.py @@ -6,11 +6,18 @@ # 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 msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,50 +27,54 @@ 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') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_authorization_rules_request( - resource_group_name: str, - namespace_name: str, - queue_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, queue_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-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_authorization_rule_request( @@ -72,47 +83,45 @@ def build_create_or_update_authorization_rule_request( queue_name: str, authorization_rule_name: str, subscription_id: str, - *, - json: Optional[_models.SBAuthorizationRule] = None, - content: Any = 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', "2018-01-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: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', min_length=1), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, "str", min_length=1), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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, - 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_authorization_rule_request( @@ -126,34 +135,37 @@ def build_delete_authorization_rule_request( _headers = case_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-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', min_length=1), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, "str", min_length=1), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_authorization_rule_request( @@ -167,34 +179,37 @@ def build_get_authorization_rule_request( _headers = case_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-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', min_length=1), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, "str", min_length=1), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_keys_request( @@ -208,34 +223,37 @@ def build_list_keys_request( _headers = case_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-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/ListKeys") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/ListKeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', min_length=1), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, "str", min_length=1), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_regenerate_keys_request( @@ -244,47 +262,45 @@ def build_regenerate_keys_request( queue_name: str, authorization_rule_name: str, subscription_id: str, - *, - json: Optional[_models.RegenerateAccessKeyParameters] = None, - content: Any = 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', "2018-01-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: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/regenerateKeys") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/regenerateKeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', min_length=1), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, "str", min_length=1), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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, - 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_by_namespace_request( @@ -299,161 +315,149 @@ def build_list_by_namespace_request( _headers = case_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-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if skip is not None: - _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', maximum=1000, minimum=0) + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", maximum=1000, minimum=0) if top is not None: - _params['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", maximum=1000, minimum=1) # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **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( - resource_group_name: str, - namespace_name: str, - queue_name: str, - subscription_id: str, - *, - json: Optional[_models.SBQueue] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_name: str, queue_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-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: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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, - 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( - resource_group_name: str, - namespace_name: str, - queue_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, queue_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-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - namespace_name: str, - queue_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, queue_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-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + class QueuesOperations: """ @@ -474,70 +478,71 @@ def __init__(self, *args, **kwargs): 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_authorization_rules( - self, - resource_group_name: str, - namespace_name: str, - queue_name: str, - **kwargs: Any - ) -> Iterable[_models.SBAuthorizationRuleListResult]: + self, resource_group_name: str, namespace_name: str, queue_name: str, **kwargs: Any + ) -> Iterable["_models.SBAuthorizationRule"]: """Gets all authorization rules for a queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of - cls(response) + :return: An iterator like instance of either SBAuthorizationRule or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRule] + :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', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRuleListResult] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[_models.SBAuthorizationRuleListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_authorization_rules_request( resource_group_name=resource_group_name, namespace_name=namespace_name, queue_name=queue_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_authorization_rules.metadata['url'], + template_url=self.list_authorization_rules.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_authorization_rules_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - queue_name=queue_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -545,16 +550,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("SBAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -565,13 +568,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_authorization_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules"} # type: ignore + list_authorization_rules.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules" + } - @distributed_trace + @overload def create_or_update_authorization_rule( self, resource_group_name: str, @@ -579,38 +582,119 @@ def create_or_update_authorization_rule( queue_name: str, authorization_rule_name: str, parameters: _models.SBAuthorizationRule, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SBAuthorizationRule: """Creates an authorization rule for a queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: The shared access authorization rule. + :param parameters: The shared access authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates an authorization rule for a queue. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Required. + :type 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: SBAuthorizationRule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: Union[_models.SBAuthorizationRule, IO], + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates an authorization rule for a queue. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRule 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: SBAuthorizationRule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SBAuthorizationRule] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'SBAuthorizationRule') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBAuthorizationRule") request = build_create_or_update_authorization_rule_request( resource_group_name=resource_group_name, @@ -621,18 +705,18 @@ def create_or_update_authorization_rule( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_authorization_rule.metadata['url'], + content=_content, + template_url=self.create_or_update_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -640,15 +724,16 @@ def create_or_update_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}"} # type: ignore - + create_or_update_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}" + } @distributed_trace def delete_authorization_rule( # pylint: disable=inconsistent-return-statements @@ -661,31 +746,35 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements ) -> None: """Deletes a queue authorization rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -693,18 +782,17 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_authorization_rule.metadata['url'], + template_url=self.delete_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -715,8 +803,9 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}"} # type: ignore - + delete_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}" + } @distributed_trace def get_authorization_rule( @@ -729,31 +818,35 @@ def get_authorization_rule( ) -> _models.SBAuthorizationRule: """Gets an authorization rule for a queue by rule name. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[_models.SBAuthorizationRule] = kwargs.pop("cls", None) - request = build_get_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -761,18 +854,17 @@ def get_authorization_rule( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_authorization_rule.metadata['url'], + template_url=self.get_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -780,15 +872,16 @@ def get_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}"} # type: ignore - + get_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}" + } @distributed_trace def list_keys( @@ -801,31 +894,35 @@ def list_keys( ) -> _models.AccessKeys: """Primary and secondary connection strings to the queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[_models.AccessKeys] = kwargs.pop("cls", None) - request = build_list_keys_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -833,18 +930,17 @@ def list_keys( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata['url'], + 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 + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -852,17 +948,18 @@ def list_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + deserialized = self._deserialize("AccessKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/ListKeys"} # type: ignore - + list_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/ListKeys" + } - @distributed_trace + @overload def regenerate_keys( self, resource_group_name: str, @@ -870,39 +967,121 @@ def regenerate_keys( queue_name: str, authorization_rule_name: str, parameters: _models.RegenerateAccessKeyParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.AccessKeys: """Regenerates the primary or secondary connection strings to the queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate the authorization rule. + :param parameters: Parameters supplied to regenerate the authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.RegenerateAccessKeyParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AccessKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AccessKeys: + """Regenerates the primary or secondary connection strings to the queue. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Required. + :type 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: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: Union[_models.RegenerateAccessKeyParameters, IO], + **kwargs: Any + ) -> _models.AccessKeys: + """Regenerates the primary or secondary connection strings to the queue. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Is either a model + type or a IO type. Required. + :type parameters: + ~azure.mgmt.servicebus.v2018_01_01_preview.models.RegenerateAccessKeyParameters 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: AccessKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AccessKeys] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RegenerateAccessKeyParameters") request = build_regenerate_keys_request( resource_group_name=resource_group_name, @@ -913,18 +1092,18 @@ def regenerate_keys( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_keys.metadata['url'], + content=_content, + template_url=self.regenerate_keys.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -932,15 +1111,16 @@ def regenerate_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + deserialized = self._deserialize("AccessKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/regenerateKeys"} # type: ignore - + regenerate_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/regenerateKeys" + } @distributed_trace def list_by_namespace( @@ -950,12 +1130,12 @@ def list_by_namespace( skip: Optional[int] = None, top: Optional[int] = None, **kwargs: Any - ) -> Iterable[_models.SBQueueListResult]: + ) -> Iterable["_models.SBQueue"]: """Gets the queues within a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :param skip: Skip is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skip @@ -965,53 +1145,58 @@ def list_by_namespace( Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBQueueListResult or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBQueueListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either SBQueue or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBQueue] + :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', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBQueueListResult] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[_models.SBQueueListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_namespace_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, - api_version=api_version, skip=skip, top=top, - template_url=self.list_by_namespace.metadata['url'], + api_version=api_version, + template_url=self.list_by_namespace.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_by_namespace_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - skip=skip, - top=top, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -1019,16 +1204,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("SBQueueListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1039,49 +1222,124 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_namespace.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues"} # type: ignore + list_by_namespace.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues" + } - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, namespace_name: str, queue_name: str, parameters: _models.SBQueue, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SBQueue: """Creates or updates a Service Bus queue. This operation is idempotent. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param parameters: Parameters supplied to create or update a queue resource. + :param parameters: Parameters supplied to create or update a queue resource. Required. :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBQueue + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBQueue or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBQueue: + """Creates or updates a Service Bus queue. This operation is idempotent. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param parameters: Parameters supplied to create or update a queue resource. Required. + :type 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: SBQueue, or the result of cls(response) + :return: SBQueue or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBQueue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + parameters: Union[_models.SBQueue, IO], + **kwargs: Any + ) -> _models.SBQueue: + """Creates or updates a Service Bus queue. This operation is idempotent. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param parameters: Parameters supplied to create or update a queue resource. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBQueue 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: SBQueue or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBQueue + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBQueue] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SBQueue] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'SBQueue') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBQueue") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -1091,18 +1349,18 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - 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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1110,67 +1368,67 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBQueue', pipeline_response) + deserialized = self._deserialize("SBQueue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}"} # type: ignore - + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}" + } @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - queue_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, queue_name: str, **kwargs: Any ) -> None: """Deletes a queue from the specified namespace in a resource group. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, queue_name=queue_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1181,60 +1439,58 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}"} # type: ignore - + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}" + } @distributed_trace - def get( - self, - resource_group_name: str, - namespace_name: str, - queue_name: str, - **kwargs: Any - ) -> _models.SBQueue: + def get(self, resource_group_name: str, namespace_name: str, queue_name: str, **kwargs: Any) -> _models.SBQueue: """Returns a description for the specified queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBQueue, or the result of cls(response) + :return: SBQueue or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBQueue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBQueue] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[_models.SBQueue] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, queue_name=queue_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1242,12 +1498,13 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBQueue', pipeline_response) + deserialized = self._deserialize("SBQueue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_regions_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_regions_operations.py index 23272e4c8cb60..461e6270abf15 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_regions_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_regions_operations.py @@ -6,11 +6,18 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,46 +27,48 @@ 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') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +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_sku_request( - subscription_id: str, - sku: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_by_sku_request(sku: 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-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/sku/{sku}/regions") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/sku/{sku}/regions" + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "sku": _SERIALIZER.url("sku", sku, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "sku": _SERIALIZER.url("sku", sku, "str", max_length=50, min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + class RegionsOperations: """ @@ -80,60 +89,64 @@ def __init__(self, *args, **kwargs): 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_sku( - self, - sku: str, - **kwargs: Any - ) -> Iterable[_models.PremiumMessagingRegionsListResult]: + def list_by_sku(self, sku: str, **kwargs: Any) -> Iterable["_models.PremiumMessagingRegions"]: """Gets the available Regions for a given sku. - :param sku: The sku type. + :param sku: The sku type. Required. :type sku: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PremiumMessagingRegionsListResult or the result of + :return: An iterator like instance of either PremiumMessagingRegions or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.PremiumMessagingRegionsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.PremiumMessagingRegions] + :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', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PremiumMessagingRegionsListResult] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[_models.PremiumMessagingRegionsListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_sku_request( - subscription_id=self._config.subscription_id, sku=sku, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_sku.metadata['url'], + template_url=self.list_by_sku.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_by_sku_request( - subscription_id=self._config.subscription_id, - sku=sku, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -141,16 +154,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("PremiumMessagingRegionsListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -161,8 +172,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_sku.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/sku/{sku}/regions"} # type: ignore + list_by_sku.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/sku/{sku}/regions"} diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_rules_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_rules_operations.py index eb30400a3be8d..35cfe6c851629 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_rules_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_rules_operations.py @@ -6,11 +6,18 @@ # 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 msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,13 +27,20 @@ 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') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +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_subscriptions_request( resource_group_name: str, namespace_name: str, @@ -41,38 +55,39 @@ def build_list_by_subscriptions_request( _headers = case_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-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, "str", max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if skip is not None: - _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', maximum=1000, minimum=0) + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", maximum=1000, minimum=0) if top is not None: - _params['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", maximum=1000, minimum=1) # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **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( @@ -82,48 +97,44 @@ def build_create_or_update_request( subscription_name: str, rule_name: str, subscription_id: str, - *, - json: Optional[_models.Rule] = None, - content: Any = 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', "2018-01-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: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - "ruleName": _SERIALIZER.url("rule_name", rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, "str", max_length=50, min_length=1), + "ruleName": _SERIALIZER.url("rule_name", rule_name, "str", max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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, - 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( @@ -138,35 +149,36 @@ def build_delete_request( _headers = case_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-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - "ruleName": _SERIALIZER.url("rule_name", rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, "str", max_length=50, min_length=1), + "ruleName": _SERIALIZER.url("rule_name", rule_name, "str", max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( @@ -181,35 +193,37 @@ def build_get_request( _headers = case_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-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - "ruleName": _SERIALIZER.url("rule_name", rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, "str", max_length=50, min_length=1), + "ruleName": _SERIALIZER.url("rule_name", rule_name, "str", max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + class RulesOperations: """ @@ -230,7 +244,6 @@ def __init__(self, *args, **kwargs): 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_subscriptions( self, @@ -241,16 +254,16 @@ def list_by_subscriptions( skip: Optional[int] = None, top: Optional[int] = None, **kwargs: Any - ) -> Iterable[_models.RuleListResult]: + ) -> Iterable["_models.Rule"]: """List all the rules within given topic-subscription. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str :param skip: Skip is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skip @@ -260,57 +273,60 @@ def list_by_subscriptions( Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RuleListResult or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.RuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Rule or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.Rule] + :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', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.RuleListResult] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[_models.RuleListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscriptions_request( resource_group_name=resource_group_name, namespace_name=namespace_name, topic_name=topic_name, subscription_name=subscription_name, subscription_id=self._config.subscription_id, - api_version=api_version, skip=skip, top=top, - template_url=self.list_by_subscriptions.metadata['url'], + api_version=api_version, + template_url=self.list_by_subscriptions.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_by_subscriptions_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - topic_name=topic_name, - subscription_name=subscription_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - skip=skip, - top=top, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -318,16 +334,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("RuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -338,13 +352,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_subscriptions.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules"} # type: ignore + list_by_subscriptions.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules" + } - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, @@ -353,40 +367,127 @@ def create_or_update( subscription_name: str, rule_name: str, parameters: _models.Rule, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.Rule: """Creates a new rule and updates an existing rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str - :param rule_name: The rule name. + :param rule_name: The rule name. Required. :type rule_name: str - :param parameters: Parameters supplied to create a rule. + :param parameters: Parameters supplied to create a rule. Required. :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.Rule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Rule, or the result of cls(response) + :return: Rule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.Rule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Rule: + """Creates a new rule and updates an existing rule. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param rule_name: The rule name. Required. + :type rule_name: str + :param parameters: Parameters supplied to create a rule. Required. + :type 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: Rule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.Rule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + rule_name: str, + parameters: Union[_models.Rule, IO], + **kwargs: Any + ) -> _models.Rule: + """Creates a new rule and updates an existing rule. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param rule_name: The rule name. Required. + :type rule_name: str + :param parameters: Parameters supplied to create a rule. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.Rule 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: Rule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.Rule + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.Rule] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Rule] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'Rule') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Rule") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -398,18 +499,18 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - 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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -417,15 +518,16 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Rule', pipeline_response) + deserialized = self._deserialize("Rule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}"} # type: ignore - + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}" + } @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -439,33 +541,37 @@ def delete( # pylint: disable=inconsistent-return-statements ) -> None: """Deletes an existing rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str - :param rule_name: The rule name. + :param rule_name: The rule name. Required. :type rule_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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -474,18 +580,17 @@ def delete( # pylint: disable=inconsistent-return-statements rule_name=rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -496,8 +601,9 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}"} # type: ignore - + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}" + } @distributed_trace def get( @@ -511,33 +617,37 @@ def get( ) -> _models.Rule: """Retrieves the description for the specified rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str - :param rule_name: The rule name. + :param rule_name: The rule name. Required. :type rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Rule, or the result of cls(response) + :return: Rule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.Rule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Rule] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[_models.Rule] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -546,18 +656,17 @@ def get( rule_name=rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -565,12 +674,13 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Rule', pipeline_response) + deserialized = self._deserialize("Rule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_subscriptions_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_subscriptions_operations.py index 2a218a0afe1ae..2e1d774984d66 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_subscriptions_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_subscriptions_operations.py @@ -6,11 +6,18 @@ # 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 msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,13 +27,20 @@ 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') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +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_topic_request( resource_group_name: str, namespace_name: str, @@ -40,37 +54,38 @@ def build_list_by_topic_request( _headers = case_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-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if skip is not None: - _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', maximum=1000, minimum=0) + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", maximum=1000, minimum=0) if top is not None: - _params['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", maximum=1000, minimum=1) # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **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( @@ -79,47 +94,43 @@ def build_create_or_update_request( topic_name: str, subscription_name: str, subscription_id: str, - *, - json: Optional[_models.SBSubscription] = None, - content: Any = 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', "2018-01-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: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, "str", max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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, - 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( @@ -133,34 +144,35 @@ def build_delete_request( _headers = case_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-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, "str", max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( @@ -174,34 +186,36 @@ def build_get_request( _headers = case_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-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, "str", max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + class SubscriptionsOperations: """ @@ -222,7 +236,6 @@ def __init__(self, *args, **kwargs): 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_topic( self, @@ -232,14 +245,14 @@ def list_by_topic( skip: Optional[int] = None, top: Optional[int] = None, **kwargs: Any - ) -> Iterable[_models.SBSubscriptionListResult]: + ) -> Iterable["_models.SBSubscription"]: """List all the subscriptions under a specified topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str :param skip: Skip is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skip @@ -249,56 +262,60 @@ def list_by_topic( Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBSubscriptionListResult or the result of - cls(response) + :return: An iterator like instance of either SBSubscription or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBSubscriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBSubscription] + :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', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBSubscriptionListResult] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[_models.SBSubscriptionListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_topic_request( resource_group_name=resource_group_name, namespace_name=namespace_name, topic_name=topic_name, subscription_id=self._config.subscription_id, - api_version=api_version, skip=skip, top=top, - template_url=self.list_by_topic.metadata['url'], + api_version=api_version, + template_url=self.list_by_topic.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_by_topic_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - topic_name=topic_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - skip=skip, - top=top, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -306,16 +323,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("SBSubscriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -326,13 +341,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_topic.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions"} # type: ignore + list_by_topic.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions" + } - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, @@ -340,38 +355,119 @@ def create_or_update( topic_name: str, subscription_name: str, parameters: _models.SBSubscription, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SBSubscription: """Creates a topic subscription. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str - :param parameters: Parameters supplied to create a subscription resource. + :param parameters: Parameters supplied to create a subscription resource. Required. :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBSubscription + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBSubscription or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBSubscription + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBSubscription: + """Creates a topic subscription. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param parameters: Parameters supplied to create a subscription resource. Required. + :type 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: SBSubscription or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBSubscription + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + parameters: Union[_models.SBSubscription, IO], + **kwargs: Any + ) -> _models.SBSubscription: + """Creates a topic subscription. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param parameters: Parameters supplied to create a subscription resource. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBSubscription 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: SBSubscription, or the result of cls(response) + :return: SBSubscription or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBSubscription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBSubscription] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SBSubscription] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'SBSubscription') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBSubscription") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -382,18 +478,18 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - 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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -401,52 +497,52 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBSubscription', pipeline_response) + deserialized = self._deserialize("SBSubscription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}"} # type: ignore - + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}" + } @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - subscription_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, topic_name: str, subscription_name: str, **kwargs: Any ) -> None: """Deletes a subscription from the specified topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -454,18 +550,17 @@ def delete( # pylint: disable=inconsistent-return-statements subscription_name=subscription_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -476,45 +571,45 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}"} # type: ignore - + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}" + } @distributed_trace def get( - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - subscription_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, topic_name: str, subscription_name: str, **kwargs: Any ) -> _models.SBSubscription: """Returns a subscription description for the specified topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBSubscription, or the result of cls(response) + :return: SBSubscription or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBSubscription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBSubscription] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[_models.SBSubscription] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -522,18 +617,17 @@ def get( subscription_name=subscription_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -541,12 +635,13 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBSubscription', pipeline_response) + deserialized = self._deserialize("SBSubscription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_topics_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_topics_operations.py index 54a52eb8ba8ea..51d5b1ead9535 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_topics_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_topics_operations.py @@ -6,11 +6,18 @@ # 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 msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,50 +27,54 @@ 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') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_authorization_rules_request( - resource_group_name: str, - namespace_name: str, - topic_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, topic_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-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_authorization_rule_request( @@ -72,47 +83,45 @@ def build_create_or_update_authorization_rule_request( topic_name: str, authorization_rule_name: str, subscription_id: str, - *, - json: Optional[_models.SBAuthorizationRule] = None, - content: Any = 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', "2018-01-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: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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, - 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_get_authorization_rule_request( @@ -126,34 +135,37 @@ def build_get_authorization_rule_request( _headers = case_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-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_authorization_rule_request( @@ -167,34 +179,37 @@ def build_delete_authorization_rule_request( _headers = case_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-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_list_keys_request( @@ -208,34 +223,37 @@ def build_list_keys_request( _headers = case_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-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/ListKeys") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/ListKeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_regenerate_keys_request( @@ -244,47 +262,45 @@ def build_regenerate_keys_request( topic_name: str, authorization_rule_name: str, subscription_id: str, - *, - json: Optional[_models.RegenerateAccessKeyParameters] = None, - content: Any = 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', "2018-01-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: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/regenerateKeys") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/regenerateKeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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, - 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_by_namespace_request( @@ -299,161 +315,149 @@ def build_list_by_namespace_request( _headers = case_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-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if skip is not None: - _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', maximum=1000, minimum=0) + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", maximum=1000, minimum=0) if top is not None: - _params['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", maximum=1000, minimum=1) # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **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( - resource_group_name: str, - namespace_name: str, - topic_name: str, - subscription_id: str, - *, - json: Optional[_models.SBTopic] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_name: str, topic_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-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: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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, - 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( - resource_group_name: str, - namespace_name: str, - topic_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, topic_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-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - namespace_name: str, - topic_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, topic_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-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + class TopicsOperations: """ @@ -474,70 +478,71 @@ def __init__(self, *args, **kwargs): 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_authorization_rules( - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - **kwargs: Any - ) -> Iterable[_models.SBAuthorizationRuleListResult]: + self, resource_group_name: str, namespace_name: str, topic_name: str, **kwargs: Any + ) -> Iterable["_models.SBAuthorizationRule"]: """Gets authorization rules for a topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of - cls(response) + :return: An iterator like instance of either SBAuthorizationRule or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRule] + :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', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRuleListResult] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[_models.SBAuthorizationRuleListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_authorization_rules_request( resource_group_name=resource_group_name, namespace_name=namespace_name, topic_name=topic_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_authorization_rules.metadata['url'], + template_url=self.list_authorization_rules.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_authorization_rules_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - topic_name=topic_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -545,16 +550,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("SBAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -565,13 +568,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_authorization_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules"} # type: ignore + list_authorization_rules.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules" + } - @distributed_trace + @overload def create_or_update_authorization_rule( self, resource_group_name: str, @@ -579,38 +582,119 @@ def create_or_update_authorization_rule( topic_name: str, authorization_rule_name: str, parameters: _models.SBAuthorizationRule, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SBAuthorizationRule: """Creates an authorization rule for the specified topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: The shared access authorization rule. + :param parameters: The shared access authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates an authorization rule for the specified topic. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Required. + :type 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: SBAuthorizationRule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: Union[_models.SBAuthorizationRule, IO], + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates an authorization rule for the specified topic. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRule 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: SBAuthorizationRule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SBAuthorizationRule] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'SBAuthorizationRule') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBAuthorizationRule") request = build_create_or_update_authorization_rule_request( resource_group_name=resource_group_name, @@ -621,18 +705,18 @@ def create_or_update_authorization_rule( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_authorization_rule.metadata['url'], + content=_content, + template_url=self.create_or_update_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -640,15 +724,16 @@ def create_or_update_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}"} # type: ignore - + create_or_update_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}" + } @distributed_trace def get_authorization_rule( @@ -661,31 +746,35 @@ def get_authorization_rule( ) -> _models.SBAuthorizationRule: """Returns the specified authorization rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[_models.SBAuthorizationRule] = kwargs.pop("cls", None) - request = build_get_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -693,18 +782,17 @@ def get_authorization_rule( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_authorization_rule.metadata['url'], + template_url=self.get_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -712,15 +800,16 @@ def get_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}"} # type: ignore - + get_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}" + } @distributed_trace def delete_authorization_rule( # pylint: disable=inconsistent-return-statements @@ -733,31 +822,35 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements ) -> None: """Deletes a topic authorization rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -765,18 +858,17 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_authorization_rule.metadata['url'], + template_url=self.delete_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -787,8 +879,9 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}"} # type: ignore - + delete_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}" + } @distributed_trace def list_keys( @@ -801,31 +894,35 @@ def list_keys( ) -> _models.AccessKeys: """Gets the primary and secondary connection strings for the topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[_models.AccessKeys] = kwargs.pop("cls", None) - request = build_list_keys_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -833,18 +930,17 @@ def list_keys( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata['url'], + 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 + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -852,17 +948,18 @@ def list_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + deserialized = self._deserialize("AccessKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/ListKeys"} # type: ignore - + list_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/ListKeys" + } - @distributed_trace + @overload def regenerate_keys( self, resource_group_name: str, @@ -870,39 +967,121 @@ def regenerate_keys( topic_name: str, authorization_rule_name: str, parameters: _models.RegenerateAccessKeyParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.AccessKeys: """Regenerates primary or secondary connection strings for the topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate the authorization rule. + :param parameters: Parameters supplied to regenerate the authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.RegenerateAccessKeyParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AccessKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AccessKeys: + """Regenerates primary or secondary connection strings for the topic. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Required. + :type 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: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: Union[_models.RegenerateAccessKeyParameters, IO], + **kwargs: Any + ) -> _models.AccessKeys: + """Regenerates primary or secondary connection strings for the topic. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Is either a model + type or a IO type. Required. + :type parameters: + ~azure.mgmt.servicebus.v2018_01_01_preview.models.RegenerateAccessKeyParameters 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: AccessKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AccessKeys] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RegenerateAccessKeyParameters") request = build_regenerate_keys_request( resource_group_name=resource_group_name, @@ -913,18 +1092,18 @@ def regenerate_keys( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_keys.metadata['url'], + content=_content, + template_url=self.regenerate_keys.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -932,15 +1111,16 @@ def regenerate_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + deserialized = self._deserialize("AccessKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/regenerateKeys"} # type: ignore - + regenerate_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/regenerateKeys" + } @distributed_trace def list_by_namespace( @@ -950,12 +1130,12 @@ def list_by_namespace( skip: Optional[int] = None, top: Optional[int] = None, **kwargs: Any - ) -> Iterable[_models.SBTopicListResult]: + ) -> Iterable["_models.SBTopic"]: """Gets all the topics in a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :param skip: Skip is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skip @@ -965,53 +1145,58 @@ def list_by_namespace( Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBTopicListResult or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBTopicListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either SBTopic or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBTopic] + :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', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBTopicListResult] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[_models.SBTopicListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_namespace_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, - api_version=api_version, skip=skip, top=top, - template_url=self.list_by_namespace.metadata['url'], + api_version=api_version, + template_url=self.list_by_namespace.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_by_namespace_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - skip=skip, - top=top, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -1019,16 +1204,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("SBTopicListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1039,49 +1222,124 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_namespace.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics"} # type: ignore + list_by_namespace.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics" + } - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, namespace_name: str, topic_name: str, parameters: _models.SBTopic, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SBTopic: """Creates a topic in the specified namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param parameters: Parameters supplied to create a topic resource. + :param parameters: Parameters supplied to create a topic resource. Required. :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBTopic + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBTopic or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBTopic + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBTopic: + """Creates a topic in the specified namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param parameters: Parameters supplied to create a topic resource. Required. + :type 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: SBTopic, or the result of cls(response) + :return: SBTopic or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBTopic - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + parameters: Union[_models.SBTopic, IO], + **kwargs: Any + ) -> _models.SBTopic: + """Creates a topic in the specified namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param parameters: Parameters supplied to create a topic resource. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBTopic 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: SBTopic or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBTopic + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBTopic] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SBTopic] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'SBTopic') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBTopic") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -1091,18 +1349,18 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - 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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1110,67 +1368,67 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBTopic', pipeline_response) + deserialized = self._deserialize("SBTopic", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}"} # type: ignore - + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}" + } @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, topic_name: str, **kwargs: Any ) -> None: """Deletes a topic from the specified namespace and resource group. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, topic_name=topic_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1181,60 +1439,58 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}"} # type: ignore - + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}" + } @distributed_trace - def get( - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - **kwargs: Any - ) -> _models.SBTopic: + def get(self, resource_group_name: str, namespace_name: str, topic_name: str, **kwargs: Any) -> _models.SBTopic: """Returns a description for the specified topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBTopic, or the result of cls(response) + :return: SBTopic or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBTopic - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBTopic] + api_version: Literal["2018-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-01-01-preview") + ) + cls: ClsType[_models.SBTopic] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, topic_name=topic_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1242,12 +1498,13 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBTopic', pipeline_response) + deserialized = self._deserialize("SBTopic", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/__init__.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/__init__.py index 221541a00fb6e..2e171d69863bf 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/__init__.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/__init__.py @@ -13,11 +13,14 @@ try: from ._patch import __all__ as _patch_all - from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import + from ._patch import * # pylint: disable=unused-wildcard-import except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['ServiceBusManagementClient'] + +__all__ = [ + "ServiceBusManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/_configuration.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/_configuration.py index d78f9e92a5dc8..4d9fd89ec82d5 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/_configuration.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from ._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential @@ -25,24 +31,19 @@ class ServiceBusManagementClientConfiguration(Configuration): # pylint: disable 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: Subscription credentials that uniquely identify a Microsoft Azure - subscription. The subscription ID forms part of the URI for every service call. + subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2021-01-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(ServiceBusManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + api_version: Literal["2021-01-01-preview"] = kwargs.pop("api_version", "2021-01-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -52,23 +53,21 @@ def __init__( 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-servicebus/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-servicebus/{}".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') + 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.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/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/_metadata.json b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/_metadata.json index 77f7bafcb3004..e422ca4615590 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/_metadata.json +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_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\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ServiceBusManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"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\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ServiceBusManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"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\": [\"ServiceBusManagementClientConfiguration\"], \".._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\": [\"ServiceBusManagementClientConfiguration\"], \"..._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": "Subscription credentials that uniquely identify a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.", + "signature": "subscription_id: str,", + "description": "Subscription credentials that uniquely identify a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. 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": "Subscription credentials that uniquely identify a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.", + "description": "Subscription credentials that uniquely identify a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. Required.", "docstring_type": "str", "required": true } @@ -48,19 +48,19 @@ "service_client_specific": { "sync": { "api_version": { - "signature": "api_version=None, # type: Optional[str]", + "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=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false }, "profile": { - "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "signature": "profile: KnownProfiles=KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", "required": false @@ -108,4 +108,4 @@ "rules": "RulesOperations", "subscriptions": "SubscriptionsOperations" } -} \ No newline at end of file +} diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/_patch.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/_patch.py index 0ad201a8c586e..f7dd32510333d 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/_patch.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/_service_bus_management_client.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/_service_bus_management_client.py index fff867ece7b1c..10eb762680c97 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/_service_bus_management_client.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/_service_bus_management_client.py @@ -9,20 +9,31 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from . import models +from . import models as _models +from .._serialization import Deserializer, Serializer from ._configuration import ServiceBusManagementClientConfiguration -from .operations import DisasterRecoveryConfigsOperations, MigrationConfigsOperations, NamespacesOperations, Operations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, QueuesOperations, RulesOperations, SubscriptionsOperations, TopicsOperations +from .operations import ( + DisasterRecoveryConfigsOperations, + MigrationConfigsOperations, + NamespacesOperations, + Operations, + PrivateEndpointConnectionsOperations, + PrivateLinkResourcesOperations, + QueuesOperations, + RulesOperations, + SubscriptionsOperations, + TopicsOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class ServiceBusManagementClient: # pylint: disable=too-many-instance-attributes + +class ServiceBusManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Azure Service Bus client for managing Namespace. :ivar namespaces: NamespacesOperations operations @@ -50,10 +61,10 @@ class ServiceBusManagementClient: # pylint: disable=too-many-instance-attribu :ivar subscriptions: SubscriptionsOperations operations :vartype subscriptions: azure.mgmt.servicebus.v2021_01_01_preview.operations.SubscriptionsOperations - :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: Subscription credentials that uniquely identify a Microsoft Azure - subscription. The subscription ID forms part of the URI for every service call. + subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -71,50 +82,35 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = ServiceBusManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = ServiceBusManagementClientConfiguration( + 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)} + 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.namespaces = NamespacesOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.namespaces = NamespacesOperations(self._client, self._config, self._serialize, self._deserialize) self.private_endpoint_connections = PrivateEndpointConnectionsOperations( self._client, self._config, self._serialize, self._deserialize ) self.private_link_resources = PrivateLinkResourcesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize - ) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) self.disaster_recovery_configs = DisasterRecoveryConfigsOperations( self._client, self._config, self._serialize, self._deserialize ) self.migration_configs = MigrationConfigsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.queues = QueuesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.topics = TopicsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.rules = RulesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.subscriptions = SubscriptionsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - + self.queues = QueuesOperations(self._client, self._config, self._serialize, self._deserialize) + self.topics = TopicsOperations(self._client, self._config, self._serialize, self._deserialize) + self.rules = RulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.subscriptions = SubscriptionsOperations(self._client, self._config, self._serialize, self._deserialize) - def _send_request( - self, - request: 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 @@ -123,7 +119,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 @@ -136,15 +132,12 @@ def _send_request( request_copy.url = self._client.format_url(request_copy.url) return self._client.send_request(request_copy, **kwargs) - def close(self): - # type: () -> None + def close(self) -> None: self._client.close() - def __enter__(self): - # type: () -> ServiceBusManagementClient + def __enter__(self) -> "ServiceBusManagementClient": self._client.__enter__() return self - def __exit__(self, *exc_details): - # type: (Any) -> None + def __exit__(self, *exc_details) -> None: self._client.__exit__(*exc_details) diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/_vendor.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/_vendor.py index 138f663c53a4e..9aad73fc743e7 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/_vendor.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_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/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/_version.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/_version.py index 920456322fa12..e5754a47ce68f 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/_version.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "8.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/__init__.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/__init__.py index e7dd87df1f939..530b8638dfd32 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/__init__.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/__init__.py @@ -10,11 +10,14 @@ try: from ._patch import __all__ as _patch_all - from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import + from ._patch import * # pylint: disable=unused-wildcard-import except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['ServiceBusManagementClient'] + +__all__ = [ + "ServiceBusManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/_configuration.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/_configuration.py index 52f2360f8f025..c1b21908084e1 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/_configuration.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from .._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential @@ -25,24 +31,19 @@ class ServiceBusManagementClientConfiguration(Configuration): # pylint: disable 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: Subscription credentials that uniquely identify a Microsoft Azure - subscription. The subscription ID forms part of the URI for every service call. + subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2021-01-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(ServiceBusManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + api_version: Literal["2021-01-01-preview"] = kwargs.pop("api_version", "2021-01-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -52,22 +53,21 @@ def __init__( 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-servicebus/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-servicebus/{}".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/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/_patch.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/_patch.py index 0ad201a8c586e..f7dd32510333d 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/_patch.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/_service_bus_management_client.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/_service_bus_management_client.py index 5bc88f3967970..85db99fa3e624 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/_service_bus_management_client.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/_service_bus_management_client.py @@ -9,20 +9,31 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from .. import models +from .. import models as _models +from ..._serialization import Deserializer, Serializer from ._configuration import ServiceBusManagementClientConfiguration -from .operations import DisasterRecoveryConfigsOperations, MigrationConfigsOperations, NamespacesOperations, Operations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, QueuesOperations, RulesOperations, SubscriptionsOperations, TopicsOperations +from .operations import ( + DisasterRecoveryConfigsOperations, + MigrationConfigsOperations, + NamespacesOperations, + Operations, + PrivateEndpointConnectionsOperations, + PrivateLinkResourcesOperations, + QueuesOperations, + RulesOperations, + SubscriptionsOperations, + TopicsOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class ServiceBusManagementClient: # pylint: disable=too-many-instance-attributes + +class ServiceBusManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Azure Service Bus client for managing Namespace. :ivar namespaces: NamespacesOperations operations @@ -51,10 +62,10 @@ class ServiceBusManagementClient: # pylint: disable=too-many-instance-attribu :ivar subscriptions: SubscriptionsOperations operations :vartype subscriptions: azure.mgmt.servicebus.v2021_01_01_preview.aio.operations.SubscriptionsOperations - :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: Subscription credentials that uniquely identify a Microsoft Azure - subscription. The subscription ID forms part of the URI for every service call. + subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -72,50 +83,35 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = ServiceBusManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = ServiceBusManagementClientConfiguration( + 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)} + 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.namespaces = NamespacesOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.namespaces = NamespacesOperations(self._client, self._config, self._serialize, self._deserialize) self.private_endpoint_connections = PrivateEndpointConnectionsOperations( self._client, self._config, self._serialize, self._deserialize ) self.private_link_resources = PrivateLinkResourcesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize - ) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) self.disaster_recovery_configs = DisasterRecoveryConfigsOperations( self._client, self._config, self._serialize, self._deserialize ) self.migration_configs = MigrationConfigsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.queues = QueuesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.topics = TopicsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.rules = RulesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.subscriptions = SubscriptionsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - + self.queues = QueuesOperations(self._client, self._config, self._serialize, self._deserialize) + self.topics = TopicsOperations(self._client, self._config, self._serialize, self._deserialize) + self.rules = RulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.subscriptions = SubscriptionsOperations(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 @@ -124,7 +120,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/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/operations/__init__.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/operations/__init__.py index 5559ccd3746c6..e5431803c533c 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/operations/__init__.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/operations/__init__.py @@ -18,19 +18,20 @@ from ._subscriptions_operations import SubscriptionsOperations from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'NamespacesOperations', - 'PrivateEndpointConnectionsOperations', - 'PrivateLinkResourcesOperations', - 'Operations', - 'DisasterRecoveryConfigsOperations', - 'MigrationConfigsOperations', - 'QueuesOperations', - 'TopicsOperations', - 'RulesOperations', - 'SubscriptionsOperations', + "NamespacesOperations", + "PrivateEndpointConnectionsOperations", + "PrivateLinkResourcesOperations", + "Operations", + "DisasterRecoveryConfigsOperations", + "MigrationConfigsOperations", + "QueuesOperations", + "TopicsOperations", + "RulesOperations", + "SubscriptionsOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/operations/_disaster_recovery_configs_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/operations/_disaster_recovery_configs_operations.py index a116fa6bf83a9..724ae78057908 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/operations/_disaster_recovery_configs_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/operations/_disaster_recovery_configs_operations.py @@ -6,10 +6,19 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,27 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._disaster_recovery_configs_operations import build_break_pairing_request, build_check_name_availability_request, build_create_or_update_request, build_delete_request, build_fail_over_request, build_get_authorization_rule_request, build_get_request, build_list_authorization_rules_request, build_list_keys_request, build_list_request -T = TypeVar('T') +from ...operations._disaster_recovery_configs_operations import ( + build_break_pairing_request, + build_check_name_availability_request, + build_create_or_update_request, + build_delete_request, + build_fail_over_request, + build_get_authorization_rule_request, + build_get_request, + build_list_authorization_rules_request, + build_list_keys_request, + build_list_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class DisasterRecoveryConfigsOperations: """ .. warning:: @@ -43,41 +69,109 @@ def __init__(self, *args, **kwargs) -> None: 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 + @overload async def check_name_availability( self, resource_group_name: str, namespace_name: str, parameters: _models.CheckNameAvailability, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Check the give namespace name availability. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: Parameters to check availability of the given namespace name. + :param parameters: Parameters to check availability of the given namespace name. Required. :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.CheckNameAvailability + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckNameAvailabilityResult, or the result of cls(response) + :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.CheckNameAvailabilityResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters to check availability of the given namespace name. Required. + :type 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: CheckNameAvailabilityResult or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_name_availability( + self, + resource_group_name: str, + namespace_name: str, + parameters: Union[_models.CheckNameAvailability, IO], + **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters to check availability of the given namespace name. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.CheckNameAvailability 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: CheckNameAvailabilityResult or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.CheckNameAvailabilityResult] - - _json = self._serialize.body(parameters, 'CheckNameAvailability') + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CheckNameAvailabilityResult] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "CheckNameAvailability") request = build_check_name_availability_request( resource_group_name=resource_group_name, @@ -86,18 +180,18 @@ async def check_name_availability( 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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -105,74 +199,79 @@ async def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) + deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/CheckNameAvailability"} # type: ignore - + check_name_availability.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/CheckNameAvailability" + } @distributed_trace def list( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.ArmDisasterRecoveryListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ArmDisasterRecovery"]: """Gets all Alias(Disaster Recovery configurations). - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ArmDisasterRecoveryListResult or the result of - cls(response) + :return: An iterator like instance of either ArmDisasterRecovery or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.ArmDisasterRecoveryListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.ArmDisasterRecovery] + :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', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ArmDisasterRecoveryListResult] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + cls: ClsType[_models.ArmDisasterRecoveryListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -180,16 +279,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("ArmDisasterRecoveryListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -200,49 +297,126 @@ 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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs" + } - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, namespace_name: str, alias: str, parameters: _models.ArmDisasterRecovery, + *, + content_type: str = "application/json", **kwargs: Any ) -> Optional[_models.ArmDisasterRecovery]: """Creates or updates a new Alias(Disaster Recovery configuration). - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: str :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). + Required. :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.ArmDisasterRecovery + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ArmDisasterRecovery, or the result of cls(response) + :return: ArmDisasterRecovery or None or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.ArmDisasterRecovery or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + alias: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> Optional[_models.ArmDisasterRecovery]: + """Creates or updates a new Alias(Disaster Recovery configuration). + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: str + :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). + Required. + :type 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: ArmDisasterRecovery or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.ArmDisasterRecovery or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + alias: str, + parameters: Union[_models.ArmDisasterRecovery, IO], + **kwargs: Any + ) -> Optional[_models.ArmDisasterRecovery]: + """Creates or updates a new Alias(Disaster Recovery configuration). + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: str + :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). Is + either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.ArmDisasterRecovery 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: ArmDisasterRecovery or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.ArmDisasterRecovery or None + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ArmDisasterRecovery]] - - _json = self._serialize.body(parameters, 'ArmDisasterRecovery') + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.ArmDisasterRecovery]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ArmDisasterRecovery") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -252,18 +426,18 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - 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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -273,67 +447,67 @@ async def create_or_update( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ArmDisasterRecovery', pipeline_response) + deserialized = self._deserialize("ArmDisasterRecovery", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}"} # type: ignore - + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}" + } @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - alias: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, alias: str, **kwargs: Any ) -> None: """Deletes an Alias(Disaster Recovery configuration). - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: 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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, alias=alias, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -344,60 +518,60 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}"} # type: ignore - + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}" + } @distributed_trace_async async def get( - self, - resource_group_name: str, - namespace_name: str, - alias: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, alias: str, **kwargs: Any ) -> _models.ArmDisasterRecovery: """Retrieves Alias(Disaster Recovery configuration) for primary or secondary namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ArmDisasterRecovery, or the result of cls(response) + :return: ArmDisasterRecovery or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.ArmDisasterRecovery - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ArmDisasterRecovery] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + cls: ClsType[_models.ArmDisasterRecovery] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, alias=alias, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -405,68 +579,68 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ArmDisasterRecovery', pipeline_response) + deserialized = self._deserialize("ArmDisasterRecovery", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}" + } @distributed_trace_async async def break_pairing( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - alias: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, alias: str, **kwargs: Any ) -> None: """This operation disables the Disaster Recovery and stops replicating changes from primary to secondary namespaces. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: 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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_break_pairing_request( resource_group_name=resource_group_name, namespace_name=namespace_name, alias=alias, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.break_pairing.metadata['url'], + template_url=self.break_pairing.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -477,50 +651,127 @@ async def break_pairing( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - break_pairing.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/breakPairing"} # type: ignore - + break_pairing.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/breakPairing" + } - @distributed_trace_async + @overload async def fail_over( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, alias: str, parameters: Optional[_models.FailoverProperties] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> None: """Invokes GEO DR failover and reconfigure the alias to point to the secondary namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: str :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). Default value is None. :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.FailoverProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default 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: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def fail_over( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + namespace_name: str, + alias: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Invokes GEO DR failover and reconfigure the alias to point to the secondary namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: str + :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). + Default value is None. + :type 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: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def fail_over( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + namespace_name: str, + alias: str, + parameters: Optional[Union[_models.FailoverProperties, IO]] = None, + **kwargs: Any + ) -> None: + """Invokes GEO DR failover and reconfigure the alias to point to the secondary namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: str + :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). Is + either a model type or a IO type. Default value is None. + :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.FailoverProperties 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: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[None] - - if parameters is not None: - _json = self._serialize.body(parameters, 'FailoverProperties') + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "FailoverProperties") + else: + _json = None request = build_fail_over_request( resource_group_name=resource_group_name, @@ -530,18 +781,18 @@ async def fail_over( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, json=_json, - template_url=self.fail_over.metadata['url'], + content=_content, + template_url=self.fail_over.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -552,72 +803,75 @@ async def fail_over( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - fail_over.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/failover"} # type: ignore - + fail_over.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/failover" + } @distributed_trace def list_authorization_rules( - self, - resource_group_name: str, - namespace_name: str, - alias: str, - **kwargs: Any - ) -> AsyncIterable[_models.SBAuthorizationRuleListResult]: + self, resource_group_name: str, namespace_name: str, alias: str, **kwargs: Any + ) -> AsyncIterable["_models.SBAuthorizationRule"]: """Gets the authorization rules for a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of - cls(response) + :return: An iterator like instance of either SBAuthorizationRule or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRule] + :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', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRuleListResult] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + cls: ClsType[_models.SBAuthorizationRuleListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_authorization_rules_request( resource_group_name=resource_group_name, namespace_name=namespace_name, alias=alias, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_authorization_rules.metadata['url'], + template_url=self.list_authorization_rules.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_authorization_rules_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - alias=alias, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -625,16 +879,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("SBAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -645,48 +897,47 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_authorization_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules"} # type: ignore + list_authorization_rules.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules" + } @distributed_trace_async async def get_authorization_rule( - self, - resource_group_name: str, - namespace_name: str, - alias: str, - authorization_rule_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, alias: str, authorization_rule_name: str, **kwargs: Any ) -> _models.SBAuthorizationRule: """Gets an authorization rule for a namespace by rule name. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + cls: ClsType[_models.SBAuthorizationRule] = kwargs.pop("cls", None) - request = build_get_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -694,18 +945,17 @@ async def get_authorization_rule( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_authorization_rule.metadata['url'], + template_url=self.get_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -713,52 +963,52 @@ async def get_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules/{authorizationRuleName}"} # type: ignore - + get_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules/{authorizationRuleName}" + } @distributed_trace_async async def list_keys( - self, - resource_group_name: str, - namespace_name: str, - alias: str, - authorization_rule_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, alias: str, authorization_rule_name: str, **kwargs: Any ) -> _models.AccessKeys: """Gets the primary and secondary connection strings for the namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + cls: ClsType[_models.AccessKeys] = kwargs.pop("cls", None) - request = build_list_keys_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -766,18 +1016,17 @@ async def list_keys( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata['url'], + 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 + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -785,12 +1034,13 @@ async def list_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + deserialized = self._deserialize("AccessKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules/{authorizationRuleName}/listKeys"} # type: ignore - + list_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules/{authorizationRuleName}/listKeys" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/operations/_migration_configs_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/operations/_migration_configs_operations.py index a50cd2ea520da..97e29178bc137 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/operations/_migration_configs_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/operations/_migration_configs_operations.py @@ -6,10 +6,19 @@ # 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, Union, cast +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod @@ -22,10 +31,23 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._migration_configs_operations import build_complete_migration_request, build_create_and_start_migration_request_initial, build_delete_request, build_get_request, build_list_request, build_revert_request -T = TypeVar('T') +from ...operations._migration_configs_operations import ( + build_complete_migration_request, + build_create_and_start_migration_request, + build_delete_request, + build_get_request, + build_list_request, + build_revert_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class MigrationConfigsOperations: """ .. warning:: @@ -45,65 +67,69 @@ def __init__(self, *args, **kwargs) -> None: 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, - namespace_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.MigrationConfigListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> AsyncIterable["_models.MigrationConfigProperties"]: """Gets all migrationConfigurations. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MigrationConfigListResult or the result of + :return: An iterator like instance of either MigrationConfigProperties or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.MigrationConfigListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.MigrationConfigProperties] + :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', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MigrationConfigListResult] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + cls: ClsType[_models.MigrationConfigListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -111,16 +137,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("MigrationConfigListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -131,35 +155,46 @@ 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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations" + } async def _create_and_start_migration_initial( self, resource_group_name: str, namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], - parameters: _models.MigrationConfigProperties, + config_name: Union[str, _models.MigrationConfigurationName], + parameters: Union[_models.MigrationConfigProperties, IO], **kwargs: Any ) -> Optional[_models.MigrationConfigProperties]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.MigrationConfigProperties]] - - _json = self._serialize.body(parameters, 'MigrationConfigProperties') - - request = build_create_and_start_migration_request_initial( + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.MigrationConfigProperties]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "MigrationConfigProperties") + + request = build_create_and_start_migration_request( resource_group_name=resource_group_name, namespace_name=namespace_name, config_name=config_name, @@ -167,57 +202,146 @@ async def _create_and_start_migration_initial( api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_and_start_migration_initial.metadata['url'], + content=_content, + template_url=self._create_and_start_migration_initial.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('MigrationConfigProperties', pipeline_response) + deserialized = self._deserialize("MigrationConfigProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_and_start_migration_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}"} # type: ignore + _create_and_start_migration_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}" + } + + @overload + async def begin_create_and_start_migration( + self, + resource_group_name: str, + namespace_name: str, + config_name: Union[str, _models.MigrationConfigurationName], + parameters: _models.MigrationConfigProperties, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.MigrationConfigProperties]: + """Creates Migration configuration and starts migration of entities from Standard to Premium + namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param config_name: The configuration name. Should always be "$default". "$default" Required. + :type config_name: str or + ~azure.mgmt.servicebus.v2021_01_01_preview.models.MigrationConfigurationName + :param parameters: Parameters required to create Migration Configuration. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.MigrationConfigProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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 MigrationConfigProperties or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.servicebus.v2021_01_01_preview.models.MigrationConfigProperties] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_and_start_migration( + self, + resource_group_name: str, + namespace_name: str, + config_name: Union[str, _models.MigrationConfigurationName], + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.MigrationConfigProperties]: + """Creates Migration configuration and starts migration of entities from Standard to Premium + namespace. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param config_name: The configuration name. Should always be "$default". "$default" Required. + :type config_name: str or + ~azure.mgmt.servicebus.v2021_01_01_preview.models.MigrationConfigurationName + :param parameters: Parameters required to create Migration Configuration. Required. + :type 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 + :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 MigrationConfigProperties or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.servicebus.v2021_01_01_preview.models.MigrationConfigProperties] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_and_start_migration( self, resource_group_name: str, namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], - parameters: _models.MigrationConfigProperties, + config_name: Union[str, _models.MigrationConfigurationName], + parameters: Union[_models.MigrationConfigProperties, IO], **kwargs: Any ) -> AsyncLROPoller[_models.MigrationConfigProperties]: """Creates Migration configuration and starts migration of entities from Standard to Premium namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :type config_name: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.MigrationConfigurationName - :param parameters: Parameters required to create Migration Configuration. + :param parameters: Parameters required to create Migration Configuration. Is either a model + type or a IO type. Required. :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.MigrationConfigProperties + 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 @@ -230,114 +354,114 @@ async def begin_create_and_start_migration( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.servicebus.v2021_01_01_preview.models.MigrationConfigProperties] - :raises: ~azure.core.exceptions.HttpResponseError + :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-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.MigrationConfigProperties] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.MigrationConfigProperties] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._create_and_start_migration_initial( # type: ignore + raw_result = await self._create_and_start_migration_initial( resource_group_name=resource_group_name, namespace_name=namespace_name, config_name=config_name, parameters=parameters, 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): - deserialized = self._deserialize('MigrationConfigProperties', pipeline_response) + deserialized = self._deserialize("MigrationConfigProperties", 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 + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create_and_start_migration.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}"} # type: ignore + begin_create_and_start_migration.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}" + } @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], + config_name: Union[str, _models.MigrationConfigurationName], **kwargs: Any ) -> None: """Deletes a MigrationConfiguration. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :type config_name: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.MigrationConfigurationName :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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, config_name=config_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -348,61 +472,65 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}"} # type: ignore - + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}" + } @distributed_trace_async async def get( self, resource_group_name: str, namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], + config_name: Union[str, _models.MigrationConfigurationName], **kwargs: Any ) -> _models.MigrationConfigProperties: """Retrieves Migration Config. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :type config_name: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.MigrationConfigurationName :keyword callable cls: A custom type or function that will be passed the direct response - :return: MigrationConfigProperties, or the result of cls(response) + :return: MigrationConfigProperties or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.MigrationConfigProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MigrationConfigProperties] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + cls: ClsType[_models.MigrationConfigProperties] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, config_name=config_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -410,70 +538,74 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('MigrationConfigProperties', pipeline_response) + deserialized = self._deserialize("MigrationConfigProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}" + } @distributed_trace_async async def complete_migration( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], + config_name: Union[str, _models.MigrationConfigurationName], **kwargs: Any ) -> None: """This operation Completes Migration of entities by pointing the connection strings to Premium namespace and any entities created after the operation will be under Premium Namespace. CompleteMigration operation will fail when entity migration is in-progress. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :type config_name: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.MigrationConfigurationName :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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_complete_migration_request( resource_group_name=resource_group_name, namespace_name=namespace_name, config_name=config_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.complete_migration.metadata['url'], + template_url=self.complete_migration.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -484,61 +616,65 @@ async def complete_migration( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - complete_migration.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/upgrade"} # type: ignore - + complete_migration.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/upgrade" + } @distributed_trace_async async def revert( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], + config_name: Union[str, _models.MigrationConfigurationName], **kwargs: Any ) -> None: """This operation reverts Migration. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :type config_name: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.MigrationConfigurationName :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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_revert_request( resource_group_name=resource_group_name, namespace_name=namespace_name, config_name=config_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.revert.metadata['url'], + template_url=self.revert.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -549,5 +685,6 @@ async def revert( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - revert.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/revert"} # type: ignore - + revert.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/revert" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/operations/_namespaces_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/operations/_namespaces_operations.py index ea9fa3f391b7c..8b0b6d96190d1 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/operations/_namespaces_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/operations/_namespaces_operations.py @@ -6,10 +6,19 @@ # 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, Union, cast +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod @@ -22,10 +31,33 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._namespaces_operations import build_check_name_availability_request, build_create_or_update_authorization_rule_request, build_create_or_update_network_rule_set_request, build_create_or_update_request_initial, build_delete_authorization_rule_request, build_delete_request_initial, build_get_authorization_rule_request, build_get_network_rule_set_request, build_get_request, build_list_authorization_rules_request, build_list_by_resource_group_request, build_list_keys_request, build_list_network_rule_sets_request, build_list_request, build_regenerate_keys_request, build_update_request -T = TypeVar('T') +from ...operations._namespaces_operations import ( + build_check_name_availability_request, + build_create_or_update_authorization_rule_request, + build_create_or_update_network_rule_set_request, + build_create_or_update_request, + build_delete_authorization_rule_request, + build_delete_request, + build_get_authorization_rule_request, + build_get_network_rule_set_request, + build_get_request, + build_list_authorization_rules_request, + build_list_by_resource_group_request, + build_list_keys_request, + build_list_network_rule_sets_request, + build_list_request, + build_regenerate_keys_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class NamespacesOperations: """ .. warning:: @@ -45,55 +77,60 @@ def __init__(self, *args, **kwargs) -> None: 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.SBNamespaceListResult]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.SBNamespace"]: """Gets all the available namespaces within the subscription, irrespective of the resource groups. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBNamespaceListResult or the result of - cls(response) + :return: An iterator like instance of either SBNamespace or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBNamespaceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBNamespace] + :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', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBNamespaceListResult] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + cls: ClsType[_models.SBNamespaceListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -101,16 +138,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("SBNamespaceListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -121,65 +156,67 @@ 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': "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/namespaces"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/namespaces"} @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.SBNamespaceListResult]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.SBNamespace"]: """Gets the available namespaces within a resource group. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. 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 SBNamespaceListResult or the result of - cls(response) + :return: An iterator like instance of either SBNamespace or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBNamespaceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBNamespace] + :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', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBNamespaceListResult] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + cls: ClsType[_models.SBNamespaceListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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'], + 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 + request.url = self._client.format_url(request.url) else: - - 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=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -187,16 +224,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("SBNamespaceListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -207,90 +242,173 @@ 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.ServiceBus/namespaces"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces" + } async def _create_or_update_initial( - self, - resource_group_name: str, - namespace_name: str, - parameters: _models.SBNamespace, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, parameters: Union[_models.SBNamespace, IO], **kwargs: Any ) -> Optional[_models.SBNamespace]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.SBNamespace]] - - _json = self._serialize.body(parameters, 'SBNamespace') - - request = build_create_or_update_request_initial( + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.SBNamespace]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBNamespace") + + request = build_create_or_update_request( resource_group_name=resource_group_name, namespace_name=namespace_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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('SBNamespace', pipeline_response) + deserialized = self._deserialize("SBNamespace", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('SBNamespace', pipeline_response) + deserialized = self._deserialize("SBNamespace", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore - + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}" + } - @distributed_trace_async + @overload async def begin_create_or_update( self, resource_group_name: str, namespace_name: str, parameters: _models.SBNamespace, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.SBNamespace]: """Creates or updates a service namespace. Once created, this namespace's resource manifest is immutable. This operation is idempotent. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: Parameters supplied to create a namespace resource. + :param parameters: Parameters supplied to create a namespace resource. Required. :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBNamespace + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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 SBNamespace or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBNamespace] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.SBNamespace]: + """Creates or updates a service namespace. Once created, this namespace's resource manifest is + immutable. This operation is idempotent. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to create a namespace resource. Required. + :type 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 + :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 SBNamespace or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBNamespace] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, resource_group_name: str, namespace_name: str, parameters: Union[_models.SBNamespace, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.SBNamespace]: + """Creates or updates a service namespace. Once created, this namespace's resource manifest is + immutable. This operation is idempotent. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to create a namespace resource. Is either a model type + or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBNamespace 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 @@ -303,121 +421,115 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBNamespace] - :raises: ~azure.core.exceptions.HttpResponseError + :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-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBNamespace] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SBNamespace] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._create_or_update_initial( # type: ignore + raw_result = await self._create_or_update_initial( resource_group_name=resource_group_name, namespace_name=namespace_name, parameters=parameters, 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): - deserialized = self._deserialize('SBNamespace', pipeline_response) + deserialized = self._deserialize("SBNamespace", 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 + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, **kwargs: Any ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request_initial( + request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + 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 + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}" + } @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete(self, resource_group_name: str, namespace_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes an existing namespace. This operation also removes all associated resources under the namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_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. @@ -429,103 +541,98 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements 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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: 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 + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, namespace_name=namespace_name, api_version=api_version, - 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 = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}" + } @distributed_trace_async - async def get( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> _models.SBNamespace: + async def get(self, resource_group_name: str, namespace_name: str, **kwargs: Any) -> _models.SBNamespace: """Gets a description for the specified namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBNamespace, or the result of cls(response) + :return: SBNamespace or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBNamespace - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBNamespace] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + cls: ClsType[_models.SBNamespace] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -533,51 +640,124 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBNamespace', pipeline_response) + deserialized = self._deserialize("SBNamespace", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}" + } + @overload + async def update( + self, + resource_group_name: str, + namespace_name: str, + parameters: _models.SBNamespaceUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> Optional[_models.SBNamespace]: + """Updates a service namespace. Once created, this namespace's resource manifest is immutable. + This operation is idempotent. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to update a namespace resource. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBNamespaceUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBNamespace or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBNamespace or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> Optional[_models.SBNamespace]: + """Updates a service namespace. Once created, this namespace's resource manifest is immutable. + This operation is idempotent. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to update a namespace resource. Required. + :type 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: SBNamespace or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBNamespace or None + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def update( self, resource_group_name: str, namespace_name: str, - parameters: _models.SBNamespaceUpdateParameters, + parameters: Union[_models.SBNamespaceUpdateParameters, IO], **kwargs: Any ) -> Optional[_models.SBNamespace]: """Updates a service namespace. Once created, this namespace's resource manifest is immutable. This operation is idempotent. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: Parameters supplied to update a namespace resource. + :param parameters: Parameters supplied to update a namespace resource. Is either a model type + or a IO type. Required. :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBNamespaceUpdateParameters + 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: SBNamespace, or the result of cls(response) + :return: SBNamespace or None or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBNamespace or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.SBNamespace]] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.SBNamespace]] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'SBNamespaceUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBNamespaceUpdateParameters") request = build_update_request( resource_group_name=resource_group_name, @@ -586,18 +766,18 @@ async def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -607,53 +787,122 @@ async def update( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('SBNamespace', pipeline_response) + deserialized = self._deserialize("SBNamespace", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('SBNamespace', pipeline_response) + deserialized = self._deserialize("SBNamespace", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore - + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}" + } - @distributed_trace_async + @overload async def create_or_update_network_rule_set( self, resource_group_name: str, namespace_name: str, parameters: _models.NetworkRuleSet, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.NetworkRuleSet: """Create or update NetworkRuleSet for a Namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: The Namespace IpFilterRule. + :param parameters: The Namespace IpFilterRule. Required. :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.NetworkRuleSet + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: NetworkRuleSet, or the result of cls(response) + :return: NetworkRuleSet or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.NetworkRuleSet - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_network_rule_set( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.NetworkRuleSet: + """Create or update NetworkRuleSet for a Namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: The Namespace IpFilterRule. Required. + :type 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: NetworkRuleSet or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.NetworkRuleSet + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update_network_rule_set( + self, + resource_group_name: str, + namespace_name: str, + parameters: Union[_models.NetworkRuleSet, IO], + **kwargs: Any + ) -> _models.NetworkRuleSet: + """Create or update NetworkRuleSet for a Namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: The Namespace IpFilterRule. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.NetworkRuleSet 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: NetworkRuleSet or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.NetworkRuleSet + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.NetworkRuleSet] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.NetworkRuleSet] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'NetworkRuleSet') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "NetworkRuleSet") request = build_create_or_update_network_rule_set_request( resource_group_name=resource_group_name, @@ -662,18 +911,18 @@ async def create_or_update_network_rule_set( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_network_rule_set.metadata['url'], + content=_content, + template_url=self.create_or_update_network_rule_set.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -681,63 +930,64 @@ async def create_or_update_network_rule_set( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('NetworkRuleSet', pipeline_response) + deserialized = self._deserialize("NetworkRuleSet", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_network_rule_set.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default"} # type: ignore - + create_or_update_network_rule_set.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default" + } @distributed_trace_async async def get_network_rule_set( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, **kwargs: Any ) -> _models.NetworkRuleSet: """Gets NetworkRuleSet for a Namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: NetworkRuleSet, or the result of cls(response) + :return: NetworkRuleSet or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.NetworkRuleSet - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.NetworkRuleSet] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + cls: ClsType[_models.NetworkRuleSet] = kwargs.pop("cls", None) - request = build_get_network_rule_set_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_network_rule_set.metadata['url'], + template_url=self.get_network_rule_set.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -745,74 +995,79 @@ async def get_network_rule_set( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('NetworkRuleSet', pipeline_response) + deserialized = self._deserialize("NetworkRuleSet", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_network_rule_set.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default"} # type: ignore - + get_network_rule_set.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default" + } @distributed_trace def list_network_rule_sets( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.NetworkRuleSetListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> AsyncIterable["_models.NetworkRuleSet"]: """Gets list of NetworkRuleSet for a Namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either NetworkRuleSetListResult or the result of - cls(response) + :return: An iterator like instance of either NetworkRuleSet or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.NetworkRuleSetListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.NetworkRuleSet] + :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', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.NetworkRuleSetListResult] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + cls: ClsType[_models.NetworkRuleSetListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_network_rule_sets_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_network_rule_sets.metadata['url'], + template_url=self.list_network_rule_sets.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_network_rule_sets_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -820,16 +1075,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("NetworkRuleSetListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -840,70 +1093,74 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_network_rule_sets.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets"} # type: ignore + list_network_rule_sets.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets" + } @distributed_trace def list_authorization_rules( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.SBAuthorizationRuleListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> AsyncIterable["_models.SBAuthorizationRule"]: """Gets the authorization rules for a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of - cls(response) + :return: An iterator like instance of either SBAuthorizationRule or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRule] + :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', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRuleListResult] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + cls: ClsType[_models.SBAuthorizationRuleListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_authorization_rules_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_authorization_rules.metadata['url'], + template_url=self.list_authorization_rules.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_authorization_rules_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -911,16 +1168,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("SBAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -931,49 +1186,124 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_authorization_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules"} # type: ignore + list_authorization_rules.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules" + } - @distributed_trace_async + @overload async def create_or_update_authorization_rule( self, resource_group_name: str, namespace_name: str, authorization_rule_name: str, parameters: _models.SBAuthorizationRule, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SBAuthorizationRule: """Creates or updates an authorization rule for a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: The shared access authorization rule. + :param parameters: The shared access authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBAuthorizationRule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates or updates an authorization rule for a namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Required. + :type 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: SBAuthorizationRule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: Union[_models.SBAuthorizationRule, IO], + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates or updates an authorization rule for a namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRule 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: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SBAuthorizationRule] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'SBAuthorizationRule') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBAuthorizationRule") request = build_create_or_update_authorization_rule_request( resource_group_name=resource_group_name, @@ -983,18 +1313,18 @@ async def create_or_update_authorization_rule( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_authorization_rule.metadata['url'], + content=_content, + template_url=self.create_or_update_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1002,67 +1332,67 @@ async def create_or_update_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}"} # type: ignore - + create_or_update_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}" + } @distributed_trace_async async def delete_authorization_rule( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, authorization_rule_name: str, **kwargs: Any ) -> None: """Deletes a namespace authorization rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_authorization_rule.metadata['url'], + template_url=self.delete_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1073,60 +1403,60 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat if cls: return cls(pipeline_response, None, {}) - delete_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}"} # type: ignore - + delete_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}" + } @distributed_trace_async async def get_authorization_rule( - self, - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, authorization_rule_name: str, **kwargs: Any ) -> _models.SBAuthorizationRule: """Gets an authorization rule for a namespace by rule name. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + cls: ClsType[_models.SBAuthorizationRule] = kwargs.pop("cls", None) - request = build_get_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_authorization_rule.metadata['url'], + template_url=self.get_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1134,67 +1464,67 @@ async def get_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}"} # type: ignore - + get_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}" + } @distributed_trace_async async def list_keys( - self, - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, authorization_rule_name: str, **kwargs: Any ) -> _models.AccessKeys: """Gets the primary and secondary connection strings for the namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + cls: ClsType[_models.AccessKeys] = kwargs.pop("cls", None) - request = build_list_keys_request( resource_group_name=resource_group_name, namespace_name=namespace_name, authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata['url'], + 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 + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1202,54 +1532,131 @@ async def list_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + deserialized = self._deserialize("AccessKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/listKeys"} # type: ignore - + list_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/listKeys" + } - @distributed_trace_async + @overload async def regenerate_keys( self, resource_group_name: str, namespace_name: str, authorization_rule_name: str, parameters: _models.RegenerateAccessKeyParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.AccessKeys: """Regenerates the primary or secondary connection strings for the namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate the authorization rule. + :param parameters: Parameters supplied to regenerate the authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.RegenerateAccessKeyParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AccessKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AccessKeys: + """Regenerates the primary or secondary connection strings for the namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Required. + :type 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: AccessKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: Union[_models.RegenerateAccessKeyParameters, IO], + **kwargs: Any + ) -> _models.AccessKeys: + """Regenerates the primary or secondary connection strings for the namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Is either a model + type or a IO type. Required. + :type parameters: + ~azure.mgmt.servicebus.v2021_01_01_preview.models.RegenerateAccessKeyParameters 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: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AccessKeys] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RegenerateAccessKeyParameters") request = build_regenerate_keys_request( resource_group_name=resource_group_name, @@ -1259,18 +1666,18 @@ async def regenerate_keys( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_keys.metadata['url'], + content=_content, + template_url=self.regenerate_keys.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1278,62 +1685,110 @@ async def regenerate_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + deserialized = self._deserialize("AccessKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/regenerateKeys"} # type: ignore + regenerate_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/regenerateKeys" + } + @overload + async def check_name_availability( + self, parameters: _models.CheckNameAvailability, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param parameters: Parameters to check availability of the given namespace name. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.CheckNameAvailability + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckNameAvailabilityResult or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param parameters: Parameters to check availability of the given namespace name. Required. + :type 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: CheckNameAvailabilityResult or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def check_name_availability( - self, - parameters: _models.CheckNameAvailability, - **kwargs: Any + self, parameters: Union[_models.CheckNameAvailability, IO], **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Check the give namespace name availability. - :param parameters: Parameters to check availability of the given namespace name. - :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.CheckNameAvailability + :param parameters: Parameters to check availability of the given namespace name. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.CheckNameAvailability 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: CheckNameAvailabilityResult, or the result of cls(response) + :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.CheckNameAvailabilityResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.CheckNameAvailabilityResult] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CheckNameAvailabilityResult] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'CheckNameAvailability') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "CheckNameAvailability") 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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1341,12 +1796,13 @@ async def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) + deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/CheckNameAvailability"} # type: ignore - + check_name_availability.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/CheckNameAvailability" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/operations/_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/operations/_operations.py index 1dd31f0daad0d..855233017b339 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/operations/_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/operations/_operations.py @@ -6,10 +6,19 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +29,15 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._operations import build_list_request -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class Operations: """ .. warning:: @@ -42,52 +57,59 @@ def __init__(self, *args, **kwargs) -> None: 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 ServiceBus 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.servicebus.v2021_01_01_preview.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_01_01_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', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_request( - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -95,16 +117,14 @@ 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) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -115,8 +135,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.ServiceBus/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.ServiceBus/operations"} diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/operations/_patch.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/operations/_patch.py index 0ad201a8c586e..f7dd32510333d 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/operations/_patch.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/operations/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/operations/_private_endpoint_connections_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/operations/_private_endpoint_connections_operations.py index 31f68d205e987..b48f03482fa49 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/operations/_private_endpoint_connections_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/operations/_private_endpoint_connections_operations.py @@ -6,10 +6,19 @@ # 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, Union, cast +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod @@ -22,10 +31,21 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._private_endpoint_connections_operations import build_create_or_update_request, build_delete_request_initial, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._private_endpoint_connections_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class PrivateEndpointConnectionsOperations: """ .. warning:: @@ -45,65 +65,69 @@ def __init__(self, *args, **kwargs) -> None: 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, - namespace_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.PrivateEndpointConnectionListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> AsyncIterable["_models.PrivateEndpointConnection"]: """Gets the available PrivateEndpointConnections within a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateEndpointConnectionListResult or the result - of cls(response) + :return: An iterator like instance of either PrivateEndpointConnection or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.PrivateEndpointConnectionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_01_01_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', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnectionListResult] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -111,16 +135,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -131,71 +153,148 @@ 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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections" + } - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, namespace_name: str, private_endpoint_connection_name: str, parameters: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Creates or updates PrivateEndpointConnections of service namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param private_endpoint_connection_name: The PrivateEndpointConnection name. Required. + :type private_endpoint_connection_name: str + :param parameters: Parameters supplied to update Status of PrivateEndPoint Connection to + namespace resource. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_01_01_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 + :return: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + private_endpoint_connection_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Creates or updates PrivateEndpointConnections of service namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param private_endpoint_connection_name: The PrivateEndpointConnection name. Required. + :type private_endpoint_connection_name: str + :param parameters: Parameters supplied to update Status of PrivateEndPoint Connection to + namespace resource. Required. + :type 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: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + private_endpoint_connection_name: str, + parameters: Union[_models.PrivateEndpointConnection, IO], **kwargs: Any ) -> _models.PrivateEndpointConnection: """Creates or updates PrivateEndpointConnections of service namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param private_endpoint_connection_name: The PrivateEndpointConnection name. + :param private_endpoint_connection_name: The PrivateEndpointConnection name. Required. :type private_endpoint_connection_name: str :param parameters: Parameters supplied to update Status of PrivateEndPoint Connection to - namespace resource. + namespace resource. Is either a model type or a IO type. Required. :type parameters: ~azure.mgmt.servicebus.v2021_01_01_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 - :return: PrivateEndpointConnection, or the result of cls(response) + :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'PrivateEndpointConnection') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PrivateEndpointConnection") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, namespace_name=namespace_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.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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -204,83 +303,81 @@ async def create_or_update( 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 + return cls(pipeline_response, deserialized, {}) # type: ignore - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + return deserialized # type: ignore + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request_initial( + request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, - subscription_id=self._config.subscription_id, 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'], + 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 + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}" + } @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, namespace_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes an existing Private Endpoint Connection. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param private_endpoint_connection_name: The PrivateEndpointConnection name. + :param private_endpoint_connection_name: The PrivateEndpointConnection name. 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. @@ -292,108 +389,104 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements 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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: 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 + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, namespace_name=namespace_name, private_endpoint_connection_name=private_endpoint_connection_name, api_version=api_version, - 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 = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}" + } @distributed_trace_async async def get( - self, - resource_group_name: str, - namespace_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> _models.PrivateEndpointConnection: """Gets a description for the specified Private Endpoint Connection. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param private_endpoint_connection_name: The PrivateEndpointConnection name. + :param private_endpoint_connection_name: The PrivateEndpointConnection name. 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.servicebus.v2021_01_01_preview.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_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'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -401,12 +494,13 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, 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.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/operations/_private_link_resources_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/operations/_private_link_resources_operations.py index e411d3ee57ee9..3183f00cd40b5 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/operations/_private_link_resources_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/operations/_private_link_resources_operations.py @@ -6,9 +6,17 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Optional, TypeVar -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -19,9 +27,15 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._private_link_resources_operations import build_get_request -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class PrivateLinkResourcesOperations: """ .. warning:: @@ -41,54 +55,53 @@ def __init__(self, *args, **kwargs) -> None: 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, - namespace_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, **kwargs: Any ) -> _models.PrivateLinkResourcesListResult: """Gets lists of resources that supports Privatelinks. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateLinkResourcesListResult, or the result of cls(response) + :return: PrivateLinkResourcesListResult or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.PrivateLinkResourcesListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateLinkResourcesListResult] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + cls: ClsType[_models.PrivateLinkResourcesListResult] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -96,12 +109,13 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateLinkResourcesListResult', pipeline_response) + deserialized = self._deserialize("PrivateLinkResourcesListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateLinkResources"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateLinkResources" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/operations/_queues_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/operations/_queues_operations.py index a0dd3b79f63ae..0776b0d4ec545 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/operations/_queues_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/operations/_queues_operations.py @@ -6,10 +6,19 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,27 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._queues_operations import build_create_or_update_authorization_rule_request, build_create_or_update_request, build_delete_authorization_rule_request, build_delete_request, build_get_authorization_rule_request, build_get_request, build_list_authorization_rules_request, build_list_by_namespace_request, build_list_keys_request, build_regenerate_keys_request -T = TypeVar('T') +from ...operations._queues_operations import ( + build_create_or_update_authorization_rule_request, + build_create_or_update_request, + build_delete_authorization_rule_request, + build_delete_request, + build_get_authorization_rule_request, + build_get_request, + build_list_authorization_rules_request, + build_list_by_namespace_request, + build_list_keys_request, + build_regenerate_keys_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class QueuesOperations: """ .. warning:: @@ -43,70 +69,71 @@ def __init__(self, *args, **kwargs) -> None: 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_authorization_rules( - self, - resource_group_name: str, - namespace_name: str, - queue_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.SBAuthorizationRuleListResult]: + self, resource_group_name: str, namespace_name: str, queue_name: str, **kwargs: Any + ) -> AsyncIterable["_models.SBAuthorizationRule"]: """Gets all authorization rules for a queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of - cls(response) + :return: An iterator like instance of either SBAuthorizationRule or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRule] + :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', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRuleListResult] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + cls: ClsType[_models.SBAuthorizationRuleListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_authorization_rules_request( resource_group_name=resource_group_name, namespace_name=namespace_name, queue_name=queue_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_authorization_rules.metadata['url'], + template_url=self.list_authorization_rules.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_authorization_rules_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - queue_name=queue_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -114,16 +141,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("SBAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -134,13 +159,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_authorization_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules"} # type: ignore + list_authorization_rules.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules" + } - @distributed_trace_async + @overload async def create_or_update_authorization_rule( self, resource_group_name: str, @@ -148,38 +173,119 @@ async def create_or_update_authorization_rule( queue_name: str, authorization_rule_name: str, parameters: _models.SBAuthorizationRule, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SBAuthorizationRule: """Creates an authorization rule for a queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: The shared access authorization rule. + :param parameters: The shared access authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBAuthorizationRule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates an authorization rule for a queue. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Required. + :type 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: SBAuthorizationRule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: Union[_models.SBAuthorizationRule, IO], + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates an authorization rule for a queue. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRule 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: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SBAuthorizationRule] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'SBAuthorizationRule') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBAuthorizationRule") request = build_create_or_update_authorization_rule_request( resource_group_name=resource_group_name, @@ -190,18 +296,18 @@ async def create_or_update_authorization_rule( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_authorization_rule.metadata['url'], + content=_content, + template_url=self.create_or_update_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -209,15 +315,16 @@ async def create_or_update_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}"} # type: ignore - + create_or_update_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}" + } @distributed_trace_async async def delete_authorization_rule( # pylint: disable=inconsistent-return-statements @@ -230,31 +337,35 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat ) -> None: """Deletes a queue authorization rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -262,18 +373,17 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_authorization_rule.metadata['url'], + template_url=self.delete_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -284,8 +394,9 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat if cls: return cls(pipeline_response, None, {}) - delete_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}"} # type: ignore - + delete_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}" + } @distributed_trace_async async def get_authorization_rule( @@ -298,31 +409,35 @@ async def get_authorization_rule( ) -> _models.SBAuthorizationRule: """Gets an authorization rule for a queue by rule name. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + cls: ClsType[_models.SBAuthorizationRule] = kwargs.pop("cls", None) - request = build_get_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -330,18 +445,17 @@ async def get_authorization_rule( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_authorization_rule.metadata['url'], + template_url=self.get_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -349,15 +463,16 @@ async def get_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}"} # type: ignore - + get_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}" + } @distributed_trace_async async def list_keys( @@ -370,31 +485,35 @@ async def list_keys( ) -> _models.AccessKeys: """Primary and secondary connection strings to the queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + cls: ClsType[_models.AccessKeys] = kwargs.pop("cls", None) - request = build_list_keys_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -402,18 +521,17 @@ async def list_keys( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata['url'], + 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 + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -421,17 +539,18 @@ async def list_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + deserialized = self._deserialize("AccessKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/ListKeys"} # type: ignore - + list_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/ListKeys" + } - @distributed_trace_async + @overload async def regenerate_keys( self, resource_group_name: str, @@ -439,39 +558,121 @@ async def regenerate_keys( queue_name: str, authorization_rule_name: str, parameters: _models.RegenerateAccessKeyParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.AccessKeys: """Regenerates the primary or secondary connection strings to the queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate the authorization rule. + :param parameters: Parameters supplied to regenerate the authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.RegenerateAccessKeyParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AccessKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AccessKeys: + """Regenerates the primary or secondary connection strings to the queue. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Required. + :type 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: AccessKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: Union[_models.RegenerateAccessKeyParameters, IO], + **kwargs: Any + ) -> _models.AccessKeys: + """Regenerates the primary or secondary connection strings to the queue. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Is either a model + type or a IO type. Required. + :type parameters: + ~azure.mgmt.servicebus.v2021_01_01_preview.models.RegenerateAccessKeyParameters 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: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AccessKeys] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RegenerateAccessKeyParameters") request = build_regenerate_keys_request( resource_group_name=resource_group_name, @@ -482,18 +683,18 @@ async def regenerate_keys( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_keys.metadata['url'], + content=_content, + template_url=self.regenerate_keys.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -501,15 +702,16 @@ async def regenerate_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + deserialized = self._deserialize("AccessKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/regenerateKeys"} # type: ignore - + regenerate_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/regenerateKeys" + } @distributed_trace def list_by_namespace( @@ -519,12 +721,12 @@ def list_by_namespace( skip: Optional[int] = None, top: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable[_models.SBQueueListResult]: + ) -> AsyncIterable["_models.SBQueue"]: """Gets the queues within a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :param skip: Skip is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skip @@ -534,53 +736,59 @@ def list_by_namespace( Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBQueueListResult or the result of cls(response) + :return: An iterator like instance of either SBQueue or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBQueueListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBQueue] + :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', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBQueueListResult] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + cls: ClsType[_models.SBQueueListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_namespace_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, - api_version=api_version, skip=skip, top=top, - template_url=self.list_by_namespace.metadata['url'], + api_version=api_version, + template_url=self.list_by_namespace.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_by_namespace_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - skip=skip, - top=top, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -588,16 +796,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("SBQueueListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -608,49 +814,124 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_namespace.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues"} # type: ignore + list_by_namespace.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues" + } - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, namespace_name: str, queue_name: str, parameters: _models.SBQueue, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SBQueue: """Creates or updates a Service Bus queue. This operation is idempotent. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param parameters: Parameters supplied to create or update a queue resource. + :param parameters: Parameters supplied to create or update a queue resource. Required. :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBQueue + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBQueue or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBQueue: + """Creates or updates a Service Bus queue. This operation is idempotent. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param parameters: Parameters supplied to create or update a queue resource. Required. + :type 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: SBQueue or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + parameters: Union[_models.SBQueue, IO], + **kwargs: Any + ) -> _models.SBQueue: + """Creates or updates a Service Bus queue. This operation is idempotent. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param parameters: Parameters supplied to create or update a queue resource. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBQueue 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: SBQueue, or the result of cls(response) + :return: SBQueue or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBQueue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBQueue] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SBQueue] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'SBQueue') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBQueue") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -660,18 +941,18 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - 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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -679,67 +960,67 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBQueue', pipeline_response) + deserialized = self._deserialize("SBQueue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}"} # type: ignore - + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}" + } @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - queue_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, queue_name: str, **kwargs: Any ) -> None: """Deletes a queue from the specified namespace in a resource group. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, queue_name=queue_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -750,60 +1031,60 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}"} # type: ignore - + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}" + } @distributed_trace_async async def get( - self, - resource_group_name: str, - namespace_name: str, - queue_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, queue_name: str, **kwargs: Any ) -> _models.SBQueue: """Returns a description for the specified queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBQueue, or the result of cls(response) + :return: SBQueue or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBQueue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBQueue] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + cls: ClsType[_models.SBQueue] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, queue_name=queue_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -811,12 +1092,13 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBQueue', pipeline_response) + deserialized = self._deserialize("SBQueue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/operations/_rules_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/operations/_rules_operations.py index 555da9b534165..94e56731e0380 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/operations/_rules_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/operations/_rules_operations.py @@ -6,10 +6,19 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,21 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._rules_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_by_subscriptions_request -T = TypeVar('T') +from ...operations._rules_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_subscriptions_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class RulesOperations: """ .. warning:: @@ -43,7 +63,6 @@ def __init__(self, *args, **kwargs) -> None: 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_subscriptions( self, @@ -54,16 +73,16 @@ def list_by_subscriptions( skip: Optional[int] = None, top: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable[_models.RuleListResult]: + ) -> AsyncIterable["_models.Rule"]: """List all the rules within given topic-subscription. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str :param skip: Skip is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skip @@ -73,57 +92,61 @@ def list_by_subscriptions( Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RuleListResult or the result of cls(response) + :return: An iterator like instance of either Rule or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.RuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.Rule] + :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', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.RuleListResult] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + cls: ClsType[_models.RuleListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscriptions_request( resource_group_name=resource_group_name, namespace_name=namespace_name, topic_name=topic_name, subscription_name=subscription_name, subscription_id=self._config.subscription_id, - api_version=api_version, skip=skip, top=top, - template_url=self.list_by_subscriptions.metadata['url'], + api_version=api_version, + template_url=self.list_by_subscriptions.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_by_subscriptions_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - topic_name=topic_name, - subscription_name=subscription_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - skip=skip, - top=top, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -131,16 +154,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("RuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -151,13 +172,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_subscriptions.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules"} # type: ignore + list_by_subscriptions.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules" + } - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, @@ -166,40 +187,127 @@ async def create_or_update( subscription_name: str, rule_name: str, parameters: _models.Rule, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.Rule: """Creates a new rule and updates an existing rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str - :param rule_name: The rule name. + :param rule_name: The rule name. Required. :type rule_name: str - :param parameters: Parameters supplied to create a rule. + :param parameters: Parameters supplied to create a rule. Required. :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.Rule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Rule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.Rule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Rule: + """Creates a new rule and updates an existing rule. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param rule_name: The rule name. Required. + :type rule_name: str + :param parameters: Parameters supplied to create a rule. Required. + :type 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: Rule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.Rule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + rule_name: str, + parameters: Union[_models.Rule, IO], + **kwargs: Any + ) -> _models.Rule: + """Creates a new rule and updates an existing rule. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param rule_name: The rule name. Required. + :type rule_name: str + :param parameters: Parameters supplied to create a rule. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.Rule 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: Rule, or the result of cls(response) + :return: Rule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.Rule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.Rule] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Rule] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'Rule') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Rule") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -211,18 +319,18 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - 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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -230,15 +338,16 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Rule', pipeline_response) + deserialized = self._deserialize("Rule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}"} # type: ignore - + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}" + } @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -252,33 +361,37 @@ async def delete( # pylint: disable=inconsistent-return-statements ) -> None: """Deletes an existing rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str - :param rule_name: The rule name. + :param rule_name: The rule name. Required. :type rule_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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -287,18 +400,17 @@ async def delete( # pylint: disable=inconsistent-return-statements rule_name=rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -309,8 +421,9 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}"} # type: ignore - + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}" + } @distributed_trace_async async def get( @@ -324,33 +437,37 @@ async def get( ) -> _models.Rule: """Retrieves the description for the specified rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str - :param rule_name: The rule name. + :param rule_name: The rule name. Required. :type rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Rule, or the result of cls(response) + :return: Rule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.Rule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Rule] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + cls: ClsType[_models.Rule] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -359,18 +476,17 @@ async def get( rule_name=rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -378,12 +494,13 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Rule', pipeline_response) + deserialized = self._deserialize("Rule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/operations/_subscriptions_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/operations/_subscriptions_operations.py index 44c8226c88442..42d3839b69acc 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/operations/_subscriptions_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/operations/_subscriptions_operations.py @@ -6,10 +6,19 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,21 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._subscriptions_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_by_topic_request -T = TypeVar('T') +from ...operations._subscriptions_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_topic_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class SubscriptionsOperations: """ .. warning:: @@ -43,7 +63,6 @@ def __init__(self, *args, **kwargs) -> None: 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_topic( self, @@ -53,14 +72,14 @@ def list_by_topic( skip: Optional[int] = None, top: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable[_models.SBSubscriptionListResult]: + ) -> AsyncIterable["_models.SBSubscription"]: """List all the subscriptions under a specified topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str :param skip: Skip is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skip @@ -70,56 +89,60 @@ def list_by_topic( Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBSubscriptionListResult or the result of - cls(response) + :return: An iterator like instance of either SBSubscription or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBSubscriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBSubscription] + :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', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBSubscriptionListResult] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + cls: ClsType[_models.SBSubscriptionListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_topic_request( resource_group_name=resource_group_name, namespace_name=namespace_name, topic_name=topic_name, subscription_id=self._config.subscription_id, - api_version=api_version, skip=skip, top=top, - template_url=self.list_by_topic.metadata['url'], + api_version=api_version, + template_url=self.list_by_topic.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_by_topic_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - topic_name=topic_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - skip=skip, - top=top, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -127,16 +150,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("SBSubscriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -147,13 +168,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_topic.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions"} # type: ignore + list_by_topic.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions" + } - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, @@ -161,38 +182,119 @@ async def create_or_update( topic_name: str, subscription_name: str, parameters: _models.SBSubscription, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SBSubscription: """Creates a topic subscription. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str - :param parameters: Parameters supplied to create a subscription resource. + :param parameters: Parameters supplied to create a subscription resource. Required. :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBSubscription + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBSubscription, or the result of cls(response) + :return: SBSubscription or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBSubscription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBSubscription: + """Creates a topic subscription. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param parameters: Parameters supplied to create a subscription resource. Required. + :type 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: SBSubscription or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBSubscription + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + parameters: Union[_models.SBSubscription, IO], + **kwargs: Any + ) -> _models.SBSubscription: + """Creates a topic subscription. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param parameters: Parameters supplied to create a subscription resource. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBSubscription 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: SBSubscription or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBSubscription + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBSubscription] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SBSubscription] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'SBSubscription') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBSubscription") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -203,18 +305,18 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - 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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -222,52 +324,52 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBSubscription', pipeline_response) + deserialized = self._deserialize("SBSubscription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}"} # type: ignore - + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}" + } @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - subscription_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, topic_name: str, subscription_name: str, **kwargs: Any ) -> None: """Deletes a subscription from the specified topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -275,18 +377,17 @@ async def delete( # pylint: disable=inconsistent-return-statements subscription_name=subscription_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -297,45 +398,45 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}"} # type: ignore - + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}" + } @distributed_trace_async async def get( - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - subscription_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, topic_name: str, subscription_name: str, **kwargs: Any ) -> _models.SBSubscription: """Returns a subscription description for the specified topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBSubscription, or the result of cls(response) + :return: SBSubscription or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBSubscription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBSubscription] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + cls: ClsType[_models.SBSubscription] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -343,18 +444,17 @@ async def get( subscription_name=subscription_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -362,12 +462,13 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBSubscription', pipeline_response) + deserialized = self._deserialize("SBSubscription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/operations/_topics_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/operations/_topics_operations.py index 7bb7d6f6ac4c6..4d2d12a4cb542 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/operations/_topics_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/operations/_topics_operations.py @@ -6,10 +6,19 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,27 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._topics_operations import build_create_or_update_authorization_rule_request, build_create_or_update_request, build_delete_authorization_rule_request, build_delete_request, build_get_authorization_rule_request, build_get_request, build_list_authorization_rules_request, build_list_by_namespace_request, build_list_keys_request, build_regenerate_keys_request -T = TypeVar('T') +from ...operations._topics_operations import ( + build_create_or_update_authorization_rule_request, + build_create_or_update_request, + build_delete_authorization_rule_request, + build_delete_request, + build_get_authorization_rule_request, + build_get_request, + build_list_authorization_rules_request, + build_list_by_namespace_request, + build_list_keys_request, + build_regenerate_keys_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class TopicsOperations: """ .. warning:: @@ -43,70 +69,71 @@ def __init__(self, *args, **kwargs) -> None: 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_authorization_rules( - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.SBAuthorizationRuleListResult]: + self, resource_group_name: str, namespace_name: str, topic_name: str, **kwargs: Any + ) -> AsyncIterable["_models.SBAuthorizationRule"]: """Gets authorization rules for a topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of - cls(response) + :return: An iterator like instance of either SBAuthorizationRule or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRule] + :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', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRuleListResult] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + cls: ClsType[_models.SBAuthorizationRuleListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_authorization_rules_request( resource_group_name=resource_group_name, namespace_name=namespace_name, topic_name=topic_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_authorization_rules.metadata['url'], + template_url=self.list_authorization_rules.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_authorization_rules_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - topic_name=topic_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -114,16 +141,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("SBAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -134,13 +159,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_authorization_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules"} # type: ignore + list_authorization_rules.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules" + } - @distributed_trace_async + @overload async def create_or_update_authorization_rule( self, resource_group_name: str, @@ -148,38 +173,119 @@ async def create_or_update_authorization_rule( topic_name: str, authorization_rule_name: str, parameters: _models.SBAuthorizationRule, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SBAuthorizationRule: """Creates an authorization rule for the specified topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: The shared access authorization rule. + :param parameters: The shared access authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBAuthorizationRule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates an authorization rule for the specified topic. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Required. + :type 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: SBAuthorizationRule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: Union[_models.SBAuthorizationRule, IO], + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates an authorization rule for the specified topic. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRule 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: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SBAuthorizationRule] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'SBAuthorizationRule') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBAuthorizationRule") request = build_create_or_update_authorization_rule_request( resource_group_name=resource_group_name, @@ -190,18 +296,18 @@ async def create_or_update_authorization_rule( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_authorization_rule.metadata['url'], + content=_content, + template_url=self.create_or_update_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -209,15 +315,16 @@ async def create_or_update_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}"} # type: ignore - + create_or_update_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}" + } @distributed_trace_async async def get_authorization_rule( @@ -230,31 +337,35 @@ async def get_authorization_rule( ) -> _models.SBAuthorizationRule: """Returns the specified authorization rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + cls: ClsType[_models.SBAuthorizationRule] = kwargs.pop("cls", None) - request = build_get_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -262,18 +373,17 @@ async def get_authorization_rule( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_authorization_rule.metadata['url'], + template_url=self.get_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -281,15 +391,16 @@ async def get_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}"} # type: ignore - + get_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}" + } @distributed_trace_async async def delete_authorization_rule( # pylint: disable=inconsistent-return-statements @@ -302,31 +413,35 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat ) -> None: """Deletes a topic authorization rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -334,18 +449,17 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_authorization_rule.metadata['url'], + template_url=self.delete_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -356,8 +470,9 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat if cls: return cls(pipeline_response, None, {}) - delete_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}"} # type: ignore - + delete_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}" + } @distributed_trace_async async def list_keys( @@ -370,31 +485,35 @@ async def list_keys( ) -> _models.AccessKeys: """Gets the primary and secondary connection strings for the topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + cls: ClsType[_models.AccessKeys] = kwargs.pop("cls", None) - request = build_list_keys_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -402,18 +521,17 @@ async def list_keys( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata['url'], + 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 + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -421,17 +539,18 @@ async def list_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + deserialized = self._deserialize("AccessKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/ListKeys"} # type: ignore - + list_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/ListKeys" + } - @distributed_trace_async + @overload async def regenerate_keys( self, resource_group_name: str, @@ -439,39 +558,121 @@ async def regenerate_keys( topic_name: str, authorization_rule_name: str, parameters: _models.RegenerateAccessKeyParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.AccessKeys: """Regenerates primary or secondary connection strings for the topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate the authorization rule. + :param parameters: Parameters supplied to regenerate the authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.RegenerateAccessKeyParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AccessKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AccessKeys: + """Regenerates primary or secondary connection strings for the topic. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Required. + :type 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: AccessKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: Union[_models.RegenerateAccessKeyParameters, IO], + **kwargs: Any + ) -> _models.AccessKeys: + """Regenerates primary or secondary connection strings for the topic. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Is either a model + type or a IO type. Required. + :type parameters: + ~azure.mgmt.servicebus.v2021_01_01_preview.models.RegenerateAccessKeyParameters 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: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AccessKeys] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RegenerateAccessKeyParameters") request = build_regenerate_keys_request( resource_group_name=resource_group_name, @@ -482,18 +683,18 @@ async def regenerate_keys( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_keys.metadata['url'], + content=_content, + template_url=self.regenerate_keys.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -501,15 +702,16 @@ async def regenerate_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + deserialized = self._deserialize("AccessKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/regenerateKeys"} # type: ignore - + regenerate_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/regenerateKeys" + } @distributed_trace def list_by_namespace( @@ -519,12 +721,12 @@ def list_by_namespace( skip: Optional[int] = None, top: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable[_models.SBTopicListResult]: + ) -> AsyncIterable["_models.SBTopic"]: """Gets all the topics in a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :param skip: Skip is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skip @@ -534,53 +736,59 @@ def list_by_namespace( Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBTopicListResult or the result of cls(response) + :return: An iterator like instance of either SBTopic or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBTopicListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBTopic] + :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', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBTopicListResult] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + cls: ClsType[_models.SBTopicListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_namespace_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, - api_version=api_version, skip=skip, top=top, - template_url=self.list_by_namespace.metadata['url'], + api_version=api_version, + template_url=self.list_by_namespace.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_by_namespace_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - skip=skip, - top=top, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -588,16 +796,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("SBTopicListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -608,49 +814,124 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_namespace.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics"} # type: ignore + list_by_namespace.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics" + } - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, namespace_name: str, topic_name: str, parameters: _models.SBTopic, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SBTopic: """Creates a topic in the specified namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param parameters: Parameters supplied to create a topic resource. + :param parameters: Parameters supplied to create a topic resource. Required. :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBTopic + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBTopic or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBTopic + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBTopic: + """Creates a topic in the specified namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param parameters: Parameters supplied to create a topic resource. Required. + :type 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: SBTopic or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBTopic + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + parameters: Union[_models.SBTopic, IO], + **kwargs: Any + ) -> _models.SBTopic: + """Creates a topic in the specified namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param parameters: Parameters supplied to create a topic resource. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBTopic 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: SBTopic, or the result of cls(response) + :return: SBTopic or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBTopic - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBTopic] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SBTopic] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'SBTopic') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBTopic") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -660,18 +941,18 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - 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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -679,67 +960,67 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBTopic', pipeline_response) + deserialized = self._deserialize("SBTopic", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}"} # type: ignore - + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}" + } @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, topic_name: str, **kwargs: Any ) -> None: """Deletes a topic from the specified namespace and resource group. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, topic_name=topic_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -750,60 +1031,60 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}"} # type: ignore - + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}" + } @distributed_trace_async async def get( - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, topic_name: str, **kwargs: Any ) -> _models.SBTopic: """Returns a description for the specified topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBTopic, or the result of cls(response) + :return: SBTopic or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBTopic - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBTopic] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + cls: ClsType[_models.SBTopic] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, topic_name=topic_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -811,12 +1092,13 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBTopic', pipeline_response) + deserialized = self._deserialize("SBTopic", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/models/__init__.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/models/__init__.py index 8da943ad1f9b1..ccc88d9ba3f98 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/models/__init__.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/models/__init__.py @@ -61,99 +61,97 @@ from ._models_py3 import TrackedResource from ._models_py3 import UserAssignedIdentityProperties - -from ._service_bus_management_client_enums import ( - AccessRights, - CreatedByType, - DefaultAction, - EndPointProvisioningState, - EntityStatus, - FilterType, - KeyType, - ManagedServiceIdentityType, - MigrationConfigurationName, - NetworkRuleIPAction, - PrivateLinkConnectionStatus, - ProvisioningStateDR, - RoleDisasterRecovery, - SkuName, - SkuTier, - UnavailableReason, -) +from ._service_bus_management_client_enums import AccessRights +from ._service_bus_management_client_enums import CreatedByType +from ._service_bus_management_client_enums import DefaultAction +from ._service_bus_management_client_enums import EndPointProvisioningState +from ._service_bus_management_client_enums import EntityStatus +from ._service_bus_management_client_enums import FilterType +from ._service_bus_management_client_enums import KeyType +from ._service_bus_management_client_enums import ManagedServiceIdentityType +from ._service_bus_management_client_enums import MigrationConfigurationName +from ._service_bus_management_client_enums import NetworkRuleIPAction +from ._service_bus_management_client_enums import PrivateLinkConnectionStatus +from ._service_bus_management_client_enums import ProvisioningStateDR +from ._service_bus_management_client_enums import RoleDisasterRecovery +from ._service_bus_management_client_enums import SkuName +from ._service_bus_management_client_enums import SkuTier +from ._service_bus_management_client_enums import UnavailableReason from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'AccessKeys', - 'Action', - 'ArmDisasterRecovery', - 'ArmDisasterRecoveryListResult', - 'CheckNameAvailability', - 'CheckNameAvailabilityResult', - 'ConnectionState', - 'CorrelationFilter', - 'DictionaryValue', - 'Encryption', - 'ErrorAdditionalInfo', - 'ErrorResponse', - 'ErrorResponseError', - 'FailoverProperties', - 'Identity', - 'KeyVaultProperties', - 'MessageCountDetails', - 'MigrationConfigListResult', - 'MigrationConfigProperties', - 'NWRuleSetIpRules', - 'NWRuleSetVirtualNetworkRules', - 'NetworkRuleSet', - 'NetworkRuleSetListResult', - 'Operation', - 'OperationDisplay', - 'OperationListResult', - 'PrivateEndpoint', - 'PrivateEndpointConnection', - 'PrivateEndpointConnectionListResult', - 'PrivateLinkResource', - 'PrivateLinkResourcesListResult', - 'RegenerateAccessKeyParameters', - 'Resource', - 'ResourceNamespacePatch', - 'Rule', - 'RuleListResult', - 'SBAuthorizationRule', - 'SBAuthorizationRuleListResult', - 'SBNamespace', - 'SBNamespaceListResult', - 'SBNamespaceUpdateParameters', - 'SBQueue', - 'SBQueueListResult', - 'SBSku', - 'SBSubscription', - 'SBSubscriptionListResult', - 'SBTopic', - 'SBTopicListResult', - 'SqlFilter', - 'SqlRuleAction', - 'Subnet', - 'SystemData', - 'TrackedResource', - 'UserAssignedIdentityProperties', - 'AccessRights', - 'CreatedByType', - 'DefaultAction', - 'EndPointProvisioningState', - 'EntityStatus', - 'FilterType', - 'KeyType', - 'ManagedServiceIdentityType', - 'MigrationConfigurationName', - 'NetworkRuleIPAction', - 'PrivateLinkConnectionStatus', - 'ProvisioningStateDR', - 'RoleDisasterRecovery', - 'SkuName', - 'SkuTier', - 'UnavailableReason', + "AccessKeys", + "Action", + "ArmDisasterRecovery", + "ArmDisasterRecoveryListResult", + "CheckNameAvailability", + "CheckNameAvailabilityResult", + "ConnectionState", + "CorrelationFilter", + "DictionaryValue", + "Encryption", + "ErrorAdditionalInfo", + "ErrorResponse", + "ErrorResponseError", + "FailoverProperties", + "Identity", + "KeyVaultProperties", + "MessageCountDetails", + "MigrationConfigListResult", + "MigrationConfigProperties", + "NWRuleSetIpRules", + "NWRuleSetVirtualNetworkRules", + "NetworkRuleSet", + "NetworkRuleSetListResult", + "Operation", + "OperationDisplay", + "OperationListResult", + "PrivateEndpoint", + "PrivateEndpointConnection", + "PrivateEndpointConnectionListResult", + "PrivateLinkResource", + "PrivateLinkResourcesListResult", + "RegenerateAccessKeyParameters", + "Resource", + "ResourceNamespacePatch", + "Rule", + "RuleListResult", + "SBAuthorizationRule", + "SBAuthorizationRuleListResult", + "SBNamespace", + "SBNamespaceListResult", + "SBNamespaceUpdateParameters", + "SBQueue", + "SBQueueListResult", + "SBSku", + "SBSubscription", + "SBSubscriptionListResult", + "SBTopic", + "SBTopicListResult", + "SqlFilter", + "SqlRuleAction", + "Subnet", + "SystemData", + "TrackedResource", + "UserAssignedIdentityProperties", + "AccessRights", + "CreatedByType", + "DefaultAction", + "EndPointProvisioningState", + "EntityStatus", + "FilterType", + "KeyType", + "ManagedServiceIdentityType", + "MigrationConfigurationName", + "NetworkRuleIPAction", + "PrivateLinkConnectionStatus", + "ProvisioningStateDR", + "RoleDisasterRecovery", + "SkuName", + "SkuTier", + "UnavailableReason", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/models/_models_py3.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/models/_models_py3.py index 0a048bd15c499..c7a9aa1575974 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/models/_models_py3.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_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,17 +8,22 @@ # -------------------------------------------------------------------------- import datetime +import sys from typing import Dict, List, Optional, TYPE_CHECKING, Union -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from ... import _serialization + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - import __init__ as _models + from .. import models as _models -class AccessKeys(msrest.serialization.Model): +class AccessKeys(_serialization.Model): """Namespace/ServiceBus Connection String. Variables are only populated by the server, and will be ignored when sending a request. @@ -45,32 +51,28 @@ class AccessKeys(msrest.serialization.Model): """ _validation = { - 'primary_connection_string': {'readonly': True}, - 'secondary_connection_string': {'readonly': True}, - 'alias_primary_connection_string': {'readonly': True}, - 'alias_secondary_connection_string': {'readonly': True}, - 'primary_key': {'readonly': True}, - 'secondary_key': {'readonly': True}, - 'key_name': {'readonly': True}, + "primary_connection_string": {"readonly": True}, + "secondary_connection_string": {"readonly": True}, + "alias_primary_connection_string": {"readonly": True}, + "alias_secondary_connection_string": {"readonly": True}, + "primary_key": {"readonly": True}, + "secondary_key": {"readonly": True}, + "key_name": {"readonly": True}, } _attribute_map = { - 'primary_connection_string': {'key': 'primaryConnectionString', 'type': 'str'}, - 'secondary_connection_string': {'key': 'secondaryConnectionString', 'type': 'str'}, - 'alias_primary_connection_string': {'key': 'aliasPrimaryConnectionString', 'type': 'str'}, - 'alias_secondary_connection_string': {'key': 'aliasSecondaryConnectionString', 'type': 'str'}, - 'primary_key': {'key': 'primaryKey', 'type': 'str'}, - 'secondary_key': {'key': 'secondaryKey', 'type': 'str'}, - 'key_name': {'key': 'keyName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - """ - """ - super(AccessKeys, self).__init__(**kwargs) + "primary_connection_string": {"key": "primaryConnectionString", "type": "str"}, + "secondary_connection_string": {"key": "secondaryConnectionString", "type": "str"}, + "alias_primary_connection_string": {"key": "aliasPrimaryConnectionString", "type": "str"}, + "alias_secondary_connection_string": {"key": "aliasSecondaryConnectionString", "type": "str"}, + "primary_key": {"key": "primaryKey", "type": "str"}, + "secondary_key": {"key": "secondaryKey", "type": "str"}, + "key_name": {"key": "keyName", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.primary_connection_string = None self.secondary_connection_string = None self.alias_primary_connection_string = None @@ -80,7 +82,7 @@ def __init__( self.key_name = None -class Action(msrest.serialization.Model): +class Action(_serialization.Model): """Represents the filter actions which are allowed for the transformation of a message that have been matched by a filter expression. :ivar sql_expression: SQL expression. e.g. MyProperty='ABC'. @@ -94,9 +96,9 @@ class Action(msrest.serialization.Model): """ _attribute_map = { - 'sql_expression': {'key': 'sqlExpression', 'type': 'str'}, - 'compatibility_level': {'key': 'compatibilityLevel', 'type': 'int'}, - 'requires_preprocessing': {'key': 'requiresPreprocessing', 'type': 'bool'}, + "sql_expression": {"key": "sqlExpression", "type": "str"}, + "compatibility_level": {"key": "compatibilityLevel", "type": "int"}, + "requires_preprocessing": {"key": "requiresPreprocessing", "type": "bool"}, } def __init__( @@ -104,7 +106,7 @@ def __init__( *, sql_expression: Optional[str] = None, compatibility_level: Optional[int] = None, - requires_preprocessing: Optional[bool] = True, + requires_preprocessing: bool = True, **kwargs ): """ @@ -117,13 +119,13 @@ def __init__( preprocessing. :paramtype requires_preprocessing: bool """ - super(Action, self).__init__(**kwargs) + super().__init__(**kwargs) self.sql_expression = sql_expression self.compatibility_level = compatibility_level self.requires_preprocessing = requires_preprocessing -class Resource(msrest.serialization.Model): +class Resource(_serialization.Model): """The Resource definition for other than namespace. Variables are only populated by the server, and will be ignored when sending a request. @@ -137,24 +139,20 @@ class Resource(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(Resource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -175,11 +173,11 @@ class ArmDisasterRecovery(Resource): :vartype system_data: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SystemData :ivar provisioning_state: Provisioning state of the Alias(Disaster Recovery configuration) - possible values 'Accepted' or 'Succeeded' or 'Failed'. Known values are: "Accepted", - "Succeeded", "Failed". + "Succeeded", and "Failed". :vartype provisioning_state: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.ProvisioningStateDR :ivar pending_replication_operations_count: Number of entities pending to be replicated. - :vartype pending_replication_operations_count: long + :vartype pending_replication_operations_count: int :ivar partner_namespace: ARM Id of the Primary/Secondary eventhub namespace name, which is part of GEO DR pairing. :vartype partner_namespace: str @@ -187,39 +185,33 @@ class ArmDisasterRecovery(Resource): pairing. :vartype alternate_name: str :ivar role: role of namespace in GEO DR - possible values 'Primary' or 'PrimaryNotReplicating' - or 'Secondary'. Known values are: "Primary", "PrimaryNotReplicating", "Secondary". + or 'Secondary'. Known values are: "Primary", "PrimaryNotReplicating", and "Secondary". :vartype role: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.RoleDisasterRecovery """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'pending_replication_operations_count': {'readonly': True}, - 'role': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "pending_replication_operations_count": {"readonly": True}, + "role": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'pending_replication_operations_count': {'key': 'properties.pendingReplicationOperationsCount', 'type': 'long'}, - 'partner_namespace': {'key': 'properties.partnerNamespace', 'type': 'str'}, - 'alternate_name': {'key': 'properties.alternateName', 'type': 'str'}, - 'role': {'key': 'properties.role', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "pending_replication_operations_count": {"key": "properties.pendingReplicationOperationsCount", "type": "int"}, + "partner_namespace": {"key": "properties.partnerNamespace", "type": "str"}, + "alternate_name": {"key": "properties.alternateName", "type": "str"}, + "role": {"key": "properties.role", "type": "str"}, } - def __init__( - self, - *, - partner_namespace: Optional[str] = None, - alternate_name: Optional[str] = None, - **kwargs - ): + def __init__(self, *, partner_namespace: Optional[str] = None, alternate_name: Optional[str] = None, **kwargs): """ :keyword partner_namespace: ARM Id of the Primary/Secondary eventhub namespace name, which is part of GEO DR pairing. @@ -228,7 +220,7 @@ def __init__( pairing. :paramtype alternate_name: str """ - super(ArmDisasterRecovery, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.provisioning_state = None self.pending_replication_operations_count = None @@ -237,7 +229,7 @@ def __init__( self.role = None -class ArmDisasterRecoveryListResult(msrest.serialization.Model): +class ArmDisasterRecoveryListResult(_serialization.Model): """The result of the List Alias(Disaster Recovery configuration) operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -250,65 +242,55 @@ class ArmDisasterRecoveryListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[ArmDisasterRecovery]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ArmDisasterRecovery]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["_models.ArmDisasterRecovery"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.ArmDisasterRecovery"]] = None, **kwargs): """ :keyword value: List of Alias(Disaster Recovery configurations). :paramtype value: list[~azure.mgmt.servicebus.v2021_01_01_preview.models.ArmDisasterRecovery] """ - super(ArmDisasterRecoveryListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class CheckNameAvailability(msrest.serialization.Model): +class CheckNameAvailability(_serialization.Model): """Description of a Check Name availability request properties. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The Name to check the namespace name availability and The namespace name - can contain only letters, numbers, and hyphens. The namespace must start with a letter, and it - must end with a letter or number. + :ivar name: The Name to check the namespace name availability and The namespace name can + contain only letters, numbers, and hyphens. The namespace must start with a letter, and it must + end with a letter or number. 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 to check the namespace name availability and The namespace - name can contain only letters, numbers, and hyphens. The namespace must start with a letter, - and it must end with a letter or number. + :keyword name: The Name to check the namespace name availability and The namespace name can + contain only letters, numbers, and hyphens. The namespace must start with a letter, and it must + end with a letter or number. Required. :paramtype name: str """ - super(CheckNameAvailability, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class CheckNameAvailabilityResult(msrest.serialization.Model): +class CheckNameAvailabilityResult(_serialization.Model): """Description of a Check Name availability request properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -319,19 +301,19 @@ class CheckNameAvailabilityResult(msrest.serialization.Model): available; otherwise, false. :vartype name_available: bool :ivar reason: The reason for unavailability of a namespace. Known values are: "None", - "InvalidName", "SubscriptionIsDisabled", "NameInUse", "NameInLockdown", + "InvalidName", "SubscriptionIsDisabled", "NameInUse", "NameInLockdown", and "TooManyNamespaceInCurrentSubscription". :vartype reason: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.UnavailableReason """ _validation = { - 'message': {'readonly': True}, + "message": {"readonly": True}, } _attribute_map = { - 'message': {'key': 'message', 'type': 'str'}, - '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"}, } def __init__( @@ -346,21 +328,21 @@ def __init__( available; otherwise, false. :paramtype name_available: bool :keyword reason: The reason for unavailability of a namespace. Known values are: "None", - "InvalidName", "SubscriptionIsDisabled", "NameInUse", "NameInLockdown", + "InvalidName", "SubscriptionIsDisabled", "NameInUse", "NameInLockdown", and "TooManyNamespaceInCurrentSubscription". :paramtype reason: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.UnavailableReason """ - super(CheckNameAvailabilityResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.message = None self.name_available = name_available self.reason = reason -class ConnectionState(msrest.serialization.Model): +class ConnectionState(_serialization.Model): """ConnectionState information. :ivar status: Status of the connection. Known values are: "Pending", "Approved", "Rejected", - "Disconnected". + and "Disconnected". :vartype status: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.PrivateLinkConnectionStatus :ivar description: Description of the connection state. @@ -368,8 +350,8 @@ class ConnectionState(msrest.serialization.Model): """ _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, + "status": {"key": "status", "type": "str"}, + "description": {"key": "description", "type": "str"}, } def __init__( @@ -381,18 +363,18 @@ def __init__( ): """ :keyword status: Status of the connection. Known values are: "Pending", "Approved", "Rejected", - "Disconnected". + and "Disconnected". :paramtype status: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.PrivateLinkConnectionStatus :keyword description: Description of the connection state. :paramtype description: str """ - super(ConnectionState, self).__init__(**kwargs) + super().__init__(**kwargs) self.status = status self.description = description -class CorrelationFilter(msrest.serialization.Model): +class CorrelationFilter(_serialization.Model): """Represents the correlation filter expression. :ivar properties: dictionary object for custom filters. @@ -419,16 +401,16 @@ class CorrelationFilter(msrest.serialization.Model): """ _attribute_map = { - 'properties': {'key': 'properties', 'type': '{str}'}, - 'correlation_id': {'key': 'correlationId', 'type': 'str'}, - 'message_id': {'key': 'messageId', 'type': 'str'}, - 'to': {'key': 'to', 'type': 'str'}, - 'reply_to': {'key': 'replyTo', 'type': 'str'}, - 'label': {'key': 'label', 'type': 'str'}, - 'session_id': {'key': 'sessionId', 'type': 'str'}, - 'reply_to_session_id': {'key': 'replyToSessionId', 'type': 'str'}, - 'content_type': {'key': 'contentType', 'type': 'str'}, - 'requires_preprocessing': {'key': 'requiresPreprocessing', 'type': 'bool'}, + "properties": {"key": "properties", "type": "{str}"}, + "correlation_id": {"key": "correlationId", "type": "str"}, + "message_id": {"key": "messageId", "type": "str"}, + "to": {"key": "to", "type": "str"}, + "reply_to": {"key": "replyTo", "type": "str"}, + "label": {"key": "label", "type": "str"}, + "session_id": {"key": "sessionId", "type": "str"}, + "reply_to_session_id": {"key": "replyToSessionId", "type": "str"}, + "content_type": {"key": "contentType", "type": "str"}, + "requires_preprocessing": {"key": "requiresPreprocessing", "type": "bool"}, } def __init__( @@ -443,7 +425,7 @@ def __init__( session_id: Optional[str] = None, reply_to_session_id: Optional[str] = None, content_type: Optional[str] = None, - requires_preprocessing: Optional[bool] = True, + requires_preprocessing: bool = True, **kwargs ): """ @@ -469,7 +451,7 @@ def __init__( preprocessing. :paramtype requires_preprocessing: bool """ - super(CorrelationFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties self.correlation_id = correlation_id self.message_id = message_id @@ -482,7 +464,7 @@ def __init__( self.requires_preprocessing = requires_preprocessing -class DictionaryValue(msrest.serialization.Model): +class DictionaryValue(_serialization.Model): """Recognized Dictionary value. Variables are only populated by the server, and will be ignored when sending a request. @@ -494,34 +476,29 @@ class DictionaryValue(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(DictionaryValue, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.principal_id = None self.client_id = None -class Encryption(msrest.serialization.Model): +class Encryption(_serialization.Model): """Properties to configure Encryption. :ivar key_vault_properties: Properties of KeyVault. :vartype key_vault_properties: list[~azure.mgmt.servicebus.v2021_01_01_preview.models.KeyVaultProperties] - :ivar key_source: Enumerates the possible value of keySource for Encryption. The only - acceptable values to pass in are None and "Microsoft.KeyVault". The default value is + :ivar key_source: Enumerates the possible value of keySource for Encryption. Default value is "Microsoft.KeyVault". :vartype key_source: str :ivar require_infrastructure_encryption: Enable Infrastructure Encryption (Double Encryption). @@ -529,16 +506,16 @@ class Encryption(msrest.serialization.Model): """ _attribute_map = { - 'key_vault_properties': {'key': 'keyVaultProperties', 'type': '[KeyVaultProperties]'}, - 'key_source': {'key': 'keySource', 'type': 'str'}, - 'require_infrastructure_encryption': {'key': 'requireInfrastructureEncryption', 'type': 'bool'}, + "key_vault_properties": {"key": "keyVaultProperties", "type": "[KeyVaultProperties]"}, + "key_source": {"key": "keySource", "type": "str"}, + "require_infrastructure_encryption": {"key": "requireInfrastructureEncryption", "type": "bool"}, } def __init__( self, *, key_vault_properties: Optional[List["_models.KeyVaultProperties"]] = None, - key_source: Optional[str] = "Microsoft.KeyVault", + key_source: Literal["Microsoft.KeyVault"] = "Microsoft.KeyVault", require_infrastructure_encryption: Optional[bool] = None, **kwargs ): @@ -546,21 +523,20 @@ def __init__( :keyword key_vault_properties: Properties of KeyVault. :paramtype key_vault_properties: list[~azure.mgmt.servicebus.v2021_01_01_preview.models.KeyVaultProperties] - :keyword key_source: Enumerates the possible value of keySource for Encryption. The only - acceptable values to pass in are None and "Microsoft.KeyVault". The default value is - "Microsoft.KeyVault". + :keyword key_source: Enumerates the possible value of keySource for Encryption. Default value + is "Microsoft.KeyVault". :paramtype key_source: str :keyword require_infrastructure_encryption: Enable Infrastructure Encryption (Double Encryption). :paramtype require_infrastructure_encryption: bool """ - super(Encryption, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_vault_properties = key_vault_properties self.key_source = key_source self.require_infrastructure_encryption = require_infrastructure_encryption -class ErrorAdditionalInfo(msrest.serialization.Model): +class ErrorAdditionalInfo(_serialization.Model): """The resource management error additional info. Variables are only populated by the server, and will be ignored when sending a request. @@ -568,31 +544,27 @@ class ErrorAdditionalInfo(msrest.serialization.Model): :ivar type: The additional info type. :vartype type: str :ivar info: The additional info. - :vartype info: any + :vartype info: JSON """ _validation = { - 'type': {'readonly': True}, - 'info': {'readonly': True}, + "type": {"readonly": True}, + "info": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'info': {'key': 'info', 'type': 'object'}, + "type": {"key": "type", "type": "str"}, + "info": {"key": "info", "type": "object"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorAdditionalInfo, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.type = None self.info = None -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_serialization.Model): """The resource management error response. :ivar error: The error object. @@ -600,24 +572,19 @@ class ErrorResponse(msrest.serialization.Model): """ _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorResponseError'}, + "error": {"key": "error", "type": "ErrorResponseError"}, } - def __init__( - self, - *, - error: Optional["_models.ErrorResponseError"] = None, - **kwargs - ): + def __init__(self, *, error: Optional["_models.ErrorResponseError"] = None, **kwargs): """ :keyword error: The error object. :paramtype error: ~azure.mgmt.servicebus.v2021_01_01_preview.models.ErrorResponseError """ - super(ErrorResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.error = error -class ErrorResponseError(msrest.serialization.Model): +class ErrorResponseError(_serialization.Model): """The error object. Variables are only populated by the server, and will be ignored when sending a request. @@ -636,28 +603,24 @@ class ErrorResponseError(msrest.serialization.Model): """ _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - 'details': {'readonly': True}, - 'additional_info': {'readonly': True}, + "code": {"readonly": True}, + "message": {"readonly": True}, + "target": {"readonly": True}, + "details": {"readonly": True}, + "additional_info": {"readonly": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ErrorResponse]'}, - 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[ErrorResponse]"}, + "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorResponseError, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.code = None self.message = None self.target = None @@ -665,7 +628,7 @@ def __init__( self.additional_info = None -class FailoverProperties(msrest.serialization.Model): +class FailoverProperties(_serialization.Model): """Safe failover is to indicate the service should wait for pending replication to finish before switching to the secondary. :ivar is_safe_failover: Safe failover is to indicate the service should wait for pending @@ -674,25 +637,20 @@ class FailoverProperties(msrest.serialization.Model): """ _attribute_map = { - 'is_safe_failover': {'key': 'properties.IsSafeFailover', 'type': 'bool'}, + "is_safe_failover": {"key": "properties.IsSafeFailover", "type": "bool"}, } - def __init__( - self, - *, - is_safe_failover: Optional[bool] = None, - **kwargs - ): + def __init__(self, *, is_safe_failover: Optional[bool] = None, **kwargs): """ :keyword is_safe_failover: Safe failover is to indicate the service should wait for pending replication to finish before switching to the secondary. :paramtype is_safe_failover: bool """ - super(FailoverProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.is_safe_failover = is_safe_failover -class Identity(msrest.serialization.Model): +class Identity(_serialization.Model): """Properties to configure User Assigned Identities for Bring your Own Keys. Variables are only populated by the server, and will be ignored when sending a request. @@ -702,7 +660,7 @@ class Identity(msrest.serialization.Model): :ivar tenant_id: TenantId from the KeyVault. :vartype tenant_id: str :ivar type: Type of managed service identity. Known values are: "SystemAssigned", - "UserAssigned", "SystemAssigned, UserAssigned", "None". + "UserAssigned", "SystemAssigned, UserAssigned", and "None". :vartype type: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.ManagedServiceIdentityType :ivar user_assigned_identities: Properties for User Assigned Identities. @@ -711,15 +669,15 @@ class Identity(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': '{DictionaryValue}'}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "user_assigned_identities": {"key": "userAssignedIdentities", "type": "{DictionaryValue}"}, } def __init__( @@ -731,21 +689,21 @@ def __init__( ): """ :keyword type: Type of managed service identity. Known values are: "SystemAssigned", - "UserAssigned", "SystemAssigned, UserAssigned", "None". + "UserAssigned", "SystemAssigned, UserAssigned", and "None". :paramtype type: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.ManagedServiceIdentityType :keyword user_assigned_identities: Properties for User Assigned Identities. :paramtype user_assigned_identities: dict[str, ~azure.mgmt.servicebus.v2021_01_01_preview.models.DictionaryValue] """ - super(Identity, 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 KeyVaultProperties(msrest.serialization.Model): +class KeyVaultProperties(_serialization.Model): """Properties to configure keyVault Properties. :ivar key_name: Name of the Key from KeyVault. @@ -760,10 +718,10 @@ class KeyVaultProperties(msrest.serialization.Model): """ _attribute_map = { - 'key_name': {'key': 'keyName', 'type': 'str'}, - 'key_vault_uri': {'key': 'keyVaultUri', 'type': 'str'}, - 'key_version': {'key': 'keyVersion', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'UserAssignedIdentityProperties'}, + "key_name": {"key": "keyName", "type": "str"}, + "key_vault_uri": {"key": "keyVaultUri", "type": "str"}, + "key_version": {"key": "keyVersion", "type": "str"}, + "identity": {"key": "identity", "type": "UserAssignedIdentityProperties"}, } def __init__( @@ -786,54 +744,50 @@ def __init__( :paramtype identity: ~azure.mgmt.servicebus.v2021_01_01_preview.models.UserAssignedIdentityProperties """ - super(KeyVaultProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_name = key_name self.key_vault_uri = key_vault_uri self.key_version = key_version self.identity = identity -class MessageCountDetails(msrest.serialization.Model): +class MessageCountDetails(_serialization.Model): """Message Count Details. Variables are only populated by the server, and will be ignored when sending a request. :ivar active_message_count: Number of active messages in the queue, topic, or subscription. - :vartype active_message_count: long + :vartype active_message_count: int :ivar dead_letter_message_count: Number of messages that are dead lettered. - :vartype dead_letter_message_count: long + :vartype dead_letter_message_count: int :ivar scheduled_message_count: Number of scheduled messages. - :vartype scheduled_message_count: long + :vartype scheduled_message_count: int :ivar transfer_message_count: Number of messages transferred to another queue, topic, or subscription. - :vartype transfer_message_count: long + :vartype transfer_message_count: int :ivar transfer_dead_letter_message_count: Number of messages transferred into dead letters. - :vartype transfer_dead_letter_message_count: long + :vartype transfer_dead_letter_message_count: int """ _validation = { - 'active_message_count': {'readonly': True}, - 'dead_letter_message_count': {'readonly': True}, - 'scheduled_message_count': {'readonly': True}, - 'transfer_message_count': {'readonly': True}, - 'transfer_dead_letter_message_count': {'readonly': True}, + "active_message_count": {"readonly": True}, + "dead_letter_message_count": {"readonly": True}, + "scheduled_message_count": {"readonly": True}, + "transfer_message_count": {"readonly": True}, + "transfer_dead_letter_message_count": {"readonly": True}, } _attribute_map = { - 'active_message_count': {'key': 'activeMessageCount', 'type': 'long'}, - 'dead_letter_message_count': {'key': 'deadLetterMessageCount', 'type': 'long'}, - 'scheduled_message_count': {'key': 'scheduledMessageCount', 'type': 'long'}, - 'transfer_message_count': {'key': 'transferMessageCount', 'type': 'long'}, - 'transfer_dead_letter_message_count': {'key': 'transferDeadLetterMessageCount', 'type': 'long'}, + "active_message_count": {"key": "activeMessageCount", "type": "int"}, + "dead_letter_message_count": {"key": "deadLetterMessageCount", "type": "int"}, + "scheduled_message_count": {"key": "scheduledMessageCount", "type": "int"}, + "transfer_message_count": {"key": "transferMessageCount", "type": "int"}, + "transfer_dead_letter_message_count": {"key": "transferDeadLetterMessageCount", "type": "int"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(MessageCountDetails, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.active_message_count = None self.dead_letter_message_count = None self.scheduled_message_count = None @@ -841,7 +795,7 @@ def __init__( self.transfer_dead_letter_message_count = None -class MigrationConfigListResult(msrest.serialization.Model): +class MigrationConfigListResult(_serialization.Model): """The result of the List migrationConfigurations operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -855,26 +809,21 @@ class MigrationConfigListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[MigrationConfigProperties]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[MigrationConfigProperties]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["_models.MigrationConfigProperties"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.MigrationConfigProperties"]] = None, **kwargs): """ :keyword value: List of Migration Configs. :paramtype value: list[~azure.mgmt.servicebus.v2021_01_01_preview.models.MigrationConfigProperties] """ - super(MigrationConfigListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None @@ -895,7 +844,7 @@ class MigrationConfigProperties(Resource): :ivar provisioning_state: Provisioning state of Migration Configuration. :vartype provisioning_state: str :ivar pending_replication_operations_count: Number of entities pending to be replicated. - :vartype pending_replication_operations_count: long + :vartype pending_replication_operations_count: int :ivar target_namespace: Existing premium Namespace ARM Id name which has no entities, will be used for migration. :vartype target_namespace: str @@ -907,34 +856,28 @@ class MigrationConfigProperties(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'pending_replication_operations_count': {'readonly': True}, - 'migration_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "pending_replication_operations_count": {"readonly": True}, + "migration_state": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'pending_replication_operations_count': {'key': 'properties.pendingReplicationOperationsCount', 'type': 'long'}, - 'target_namespace': {'key': 'properties.targetNamespace', 'type': 'str'}, - 'post_migration_name': {'key': 'properties.postMigrationName', 'type': 'str'}, - 'migration_state': {'key': 'properties.migrationState', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "pending_replication_operations_count": {"key": "properties.pendingReplicationOperationsCount", "type": "int"}, + "target_namespace": {"key": "properties.targetNamespace", "type": "str"}, + "post_migration_name": {"key": "properties.postMigrationName", "type": "str"}, + "migration_state": {"key": "properties.migrationState", "type": "str"}, } - def __init__( - self, - *, - target_namespace: Optional[str] = None, - post_migration_name: Optional[str] = None, - **kwargs - ): + def __init__(self, *, target_namespace: Optional[str] = None, post_migration_name: Optional[str] = None, **kwargs): """ :keyword target_namespace: Existing premium Namespace ARM Id name which has no entities, will be used for migration. @@ -942,7 +885,7 @@ def __init__( :keyword post_migration_name: Name to access Standard Namespace after migration. :paramtype post_migration_name: str """ - super(MigrationConfigProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.provisioning_state = None self.pending_replication_operations_count = None @@ -964,7 +907,8 @@ class NetworkRuleSet(Resource): :vartype type: str :ivar system_data: The system meta data relating to this resource. :vartype system_data: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SystemData - :ivar default_action: Default Action for Network Rule Set. Known values are: "Allow", "Deny". + :ivar default_action: Default Action for Network Rule Set. Known values are: "Allow" and + "Deny". :vartype default_action: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.DefaultAction :ivar virtual_network_rules: List VirtualNetwork Rules. :vartype virtual_network_rules: @@ -974,20 +918,20 @@ class NetworkRuleSet(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'default_action': {'key': 'properties.defaultAction', 'type': 'str'}, - 'virtual_network_rules': {'key': 'properties.virtualNetworkRules', 'type': '[NWRuleSetVirtualNetworkRules]'}, - 'ip_rules': {'key': 'properties.ipRules', 'type': '[NWRuleSetIpRules]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "default_action": {"key": "properties.defaultAction", "type": "str"}, + "virtual_network_rules": {"key": "properties.virtualNetworkRules", "type": "[NWRuleSetVirtualNetworkRules]"}, + "ip_rules": {"key": "properties.ipRules", "type": "[NWRuleSetIpRules]"}, } def __init__( @@ -999,7 +943,7 @@ def __init__( **kwargs ): """ - :keyword default_action: Default Action for Network Rule Set. Known values are: "Allow", + :keyword default_action: Default Action for Network Rule Set. Known values are: "Allow" and "Deny". :paramtype default_action: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.DefaultAction @@ -1009,14 +953,14 @@ def __init__( :keyword ip_rules: List of IpRules. :paramtype ip_rules: list[~azure.mgmt.servicebus.v2021_01_01_preview.models.NWRuleSetIpRules] """ - super(NetworkRuleSet, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.default_action = default_action self.virtual_network_rules = virtual_network_rules self.ip_rules = ip_rules -class NetworkRuleSetListResult(msrest.serialization.Model): +class NetworkRuleSetListResult(_serialization.Model): """The response of the List NetworkRuleSet operation. :ivar value: Result of the List NetworkRuleSet operation. @@ -1027,16 +971,12 @@ class NetworkRuleSetListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[NetworkRuleSet]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[NetworkRuleSet]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["_models.NetworkRuleSet"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.NetworkRuleSet"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Result of the List NetworkRuleSet operation. @@ -1045,44 +985,40 @@ def __init__( list of NetworkRuleSet. :paramtype next_link: str """ - super(NetworkRuleSetListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class NWRuleSetIpRules(msrest.serialization.Model): +class NWRuleSetIpRules(_serialization.Model): """Description of NetWorkRuleSet - IpRules resource. :ivar ip_mask: IP Mask. :vartype ip_mask: str - :ivar action: The IP Filter Action. Known values are: "Allow". Default value: "Allow". + :ivar action: The IP Filter Action. "Allow" :vartype action: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.NetworkRuleIPAction """ _attribute_map = { - 'ip_mask': {'key': 'ipMask', 'type': 'str'}, - 'action': {'key': 'action', 'type': 'str'}, + "ip_mask": {"key": "ipMask", "type": "str"}, + "action": {"key": "action", "type": "str"}, } def __init__( - self, - *, - ip_mask: Optional[str] = None, - action: Optional[Union[str, "_models.NetworkRuleIPAction"]] = "Allow", - **kwargs + self, *, ip_mask: Optional[str] = None, action: Union[str, "_models.NetworkRuleIPAction"] = "Allow", **kwargs ): """ :keyword ip_mask: IP Mask. :paramtype ip_mask: str - :keyword action: The IP Filter Action. Known values are: "Allow". Default value: "Allow". + :keyword action: The IP Filter Action. "Allow" :paramtype action: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.NetworkRuleIPAction """ - super(NWRuleSetIpRules, self).__init__(**kwargs) + super().__init__(**kwargs) self.ip_mask = ip_mask self.action = action -class NWRuleSetVirtualNetworkRules(msrest.serialization.Model): +class NWRuleSetVirtualNetworkRules(_serialization.Model): """Description of VirtualNetworkRules - NetworkRules resource. :ivar subnet: Subnet properties. @@ -1093,8 +1029,8 @@ class NWRuleSetVirtualNetworkRules(msrest.serialization.Model): """ _attribute_map = { - 'subnet': {'key': 'subnet', 'type': 'Subnet'}, - 'ignore_missing_vnet_service_endpoint': {'key': 'ignoreMissingVnetServiceEndpoint', 'type': 'bool'}, + "subnet": {"key": "subnet", "type": "Subnet"}, + "ignore_missing_vnet_service_endpoint": {"key": "ignoreMissingVnetServiceEndpoint", "type": "bool"}, } def __init__( @@ -1111,12 +1047,12 @@ def __init__( VNet Service Endpoint. :paramtype ignore_missing_vnet_service_endpoint: bool """ - super(NWRuleSetVirtualNetworkRules, self).__init__(**kwargs) + super().__init__(**kwargs) self.subnet = subnet self.ignore_missing_vnet_service_endpoint = ignore_missing_vnet_service_endpoint -class Operation(msrest.serialization.Model): +class Operation(_serialization.Model): """A ServiceBus REST API operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -1128,30 +1064,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["_models.OperationDisplay"] = None, - **kwargs - ): + def __init__(self, *, display: Optional["_models.OperationDisplay"] = None, **kwargs): """ :keyword display: The object that represents the operation. :paramtype display: ~azure.mgmt.servicebus.v2021_01_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. @@ -1165,30 +1096,26 @@ 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 OperationListResult(msrest.serialization.Model): +class OperationListResult(_serialization.Model): """Result of the request to list ServiceBus 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. @@ -1201,27 +1128,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): """PrivateEndpoint information. :ivar id: The ARM identifier for Private Endpoint. @@ -1229,20 +1152,15 @@ class PrivateEndpoint(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - *, - id: Optional[str] = None, - **kwargs - ): + def __init__(self, *, id: Optional[str] = None, **kwargs): # pylint: disable=redefined-builtin """ :keyword id: The ARM identifier for Private Endpoint. :paramtype id: str """ - super(PrivateEndpoint, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id @@ -1265,26 +1183,29 @@ class PrivateEndpointConnection(Resource): :vartype private_link_service_connection_state: ~azure.mgmt.servicebus.v2021_01_01_preview.models.ConnectionState :ivar provisioning_state: Provisioning state of the Private Endpoint Connection. Known values - are: "Creating", "Updating", "Deleting", "Succeeded", "Canceled", "Failed". + are: "Creating", "Updating", "Deleting", "Succeeded", "Canceled", and "Failed". :vartype provisioning_state: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.EndPointProvisioningState """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'private_endpoint': {'key': 'properties.privateEndpoint', 'type': 'PrivateEndpoint'}, - 'private_link_service_connection_state': {'key': 'properties.privateLinkServiceConnectionState', 'type': 'ConnectionState'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "private_endpoint": {"key": "properties.privateEndpoint", "type": "PrivateEndpoint"}, + "private_link_service_connection_state": { + "key": "properties.privateLinkServiceConnectionState", + "type": "ConnectionState", + }, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, } def __init__( @@ -1302,18 +1223,18 @@ def __init__( :paramtype private_link_service_connection_state: ~azure.mgmt.servicebus.v2021_01_01_preview.models.ConnectionState :keyword provisioning_state: Provisioning state of the Private Endpoint Connection. Known - values are: "Creating", "Updating", "Deleting", "Succeeded", "Canceled", "Failed". + values are: "Creating", "Updating", "Deleting", "Succeeded", "Canceled", and "Failed". :paramtype provisioning_state: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.EndPointProvisioningState """ - super(PrivateEndpointConnection, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.private_endpoint = private_endpoint self.private_link_service_connection_state = private_link_service_connection_state self.provisioning_state = provisioning_state -class PrivateEndpointConnectionListResult(msrest.serialization.Model): +class PrivateEndpointConnectionListResult(_serialization.Model): """Result of the list of all private endpoint connections operation. :ivar value: A collection of private endpoint connection resources. @@ -1324,8 +1245,8 @@ class PrivateEndpointConnectionListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PrivateEndpointConnection]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[PrivateEndpointConnection]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( @@ -1342,12 +1263,12 @@ def __init__( :keyword next_link: A link for the next page of private endpoint connection resources. :paramtype next_link: str """ - super(PrivateEndpointConnectionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class PrivateLinkResource(msrest.serialization.Model): +class PrivateLinkResource(_serialization.Model): """Information of the private link resource. :ivar id: Fully qualified identifier of the resource. @@ -1365,18 +1286,18 @@ class PrivateLinkResource(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'group_id': {'key': 'properties.groupId', 'type': 'str'}, - 'required_members': {'key': 'properties.requiredMembers', 'type': '[str]'}, - 'required_zone_names': {'key': 'properties.requiredZoneNames', 'type': '[str]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "group_id": {"key": "properties.groupId", "type": "str"}, + "required_members": {"key": "properties.requiredMembers", "type": "[str]"}, + "required_zone_names": {"key": "properties.requiredZoneNames", "type": "[str]"}, } def __init__( self, *, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin name: Optional[str] = None, type: Optional[str] = None, group_id: Optional[str] = None, @@ -1398,7 +1319,7 @@ def __init__( :keyword required_zone_names: Required Zone Names. :paramtype required_zone_names: list[str] """ - super(PrivateLinkResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.name = name self.type = type @@ -1407,7 +1328,7 @@ def __init__( self.required_zone_names = required_zone_names -class PrivateLinkResourcesListResult(msrest.serialization.Model): +class PrivateLinkResourcesListResult(_serialization.Model): """Result of the List private link resources operation. :ivar value: A collection of private link resources. @@ -1417,16 +1338,12 @@ class PrivateLinkResourcesListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PrivateLinkResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[PrivateLinkResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["_models.PrivateLinkResource"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.PrivateLinkResource"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: A collection of private link resources. @@ -1434,17 +1351,17 @@ def __init__( :keyword next_link: A link for the next page of private link resources. :paramtype next_link: str """ - super(PrivateLinkResourcesListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class RegenerateAccessKeyParameters(msrest.serialization.Model): +class RegenerateAccessKeyParameters(_serialization.Model): """Parameters supplied to the Regenerate Authorization Rule operation, specifies which key needs to be reset. All required parameters must be populated in order to send to Azure. - :ivar key_type: Required. The access key to regenerate. Known values are: "PrimaryKey", + :ivar key_type: The access key to regenerate. Required. Known values are: "PrimaryKey" and "SecondaryKey". :vartype key_type: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.KeyType :ivar key: Optional, if the key value provided, is reset for KeyType value or autogenerate Key @@ -1453,30 +1370,24 @@ class RegenerateAccessKeyParameters(msrest.serialization.Model): """ _validation = { - 'key_type': {'required': True}, + "key_type": {"required": True}, } _attribute_map = { - 'key_type': {'key': 'keyType', 'type': 'str'}, - 'key': {'key': 'key', 'type': 'str'}, + "key_type": {"key": "keyType", "type": "str"}, + "key": {"key": "key", "type": "str"}, } - def __init__( - self, - *, - key_type: Union[str, "_models.KeyType"], - key: Optional[str] = None, - **kwargs - ): + def __init__(self, *, key_type: Union[str, "_models.KeyType"], key: Optional[str] = None, **kwargs): """ - :keyword key_type: Required. The access key to regenerate. Known values are: "PrimaryKey", + :keyword key_type: The access key to regenerate. Required. Known values are: "PrimaryKey" and "SecondaryKey". :paramtype key_type: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.KeyType :keyword key: Optional, if the key value provided, is reset for KeyType value or autogenerate Key value set for keyType. :paramtype key: str """ - super(RegenerateAccessKeyParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_type = key_type self.key = key @@ -1494,38 +1405,32 @@ class ResourceNamespacePatch(Resource): :vartype type: str :ivar location: Resource location. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"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}'}, + "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: Optional[str] = None, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, **kwargs): """ :keyword location: Resource location. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] """ - super(ResourceNamespacePatch, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.tags = tags @@ -1547,7 +1452,7 @@ class Rule(Resource): message that have been matched by a filter expression. :vartype action: ~azure.mgmt.servicebus.v2021_01_01_preview.models.Action :ivar filter_type: Filter type that is evaluated against a BrokeredMessage. Known values are: - "SqlFilter", "CorrelationFilter". + "SqlFilter" and "CorrelationFilter". :vartype filter_type: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.FilterType :ivar sql_filter: Properties of sqlFilter. :vartype sql_filter: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SqlFilter @@ -1557,21 +1462,21 @@ class Rule(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'action': {'key': 'properties.action', 'type': 'Action'}, - 'filter_type': {'key': 'properties.filterType', 'type': 'str'}, - 'sql_filter': {'key': 'properties.sqlFilter', 'type': 'SqlFilter'}, - 'correlation_filter': {'key': 'properties.correlationFilter', 'type': 'CorrelationFilter'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "action": {"key": "properties.action", "type": "Action"}, + "filter_type": {"key": "properties.filterType", "type": "str"}, + "sql_filter": {"key": "properties.sqlFilter", "type": "SqlFilter"}, + "correlation_filter": {"key": "properties.correlationFilter", "type": "CorrelationFilter"}, } def __init__( @@ -1588,7 +1493,7 @@ def __init__( message that have been matched by a filter expression. :paramtype action: ~azure.mgmt.servicebus.v2021_01_01_preview.models.Action :keyword filter_type: Filter type that is evaluated against a BrokeredMessage. Known values - are: "SqlFilter", "CorrelationFilter". + are: "SqlFilter" and "CorrelationFilter". :paramtype filter_type: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.FilterType :keyword sql_filter: Properties of sqlFilter. :paramtype sql_filter: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SqlFilter @@ -1596,7 +1501,7 @@ def __init__( :paramtype correlation_filter: ~azure.mgmt.servicebus.v2021_01_01_preview.models.CorrelationFilter """ - super(Rule, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.action = action self.filter_type = filter_type @@ -1604,7 +1509,7 @@ def __init__( self.correlation_filter = correlation_filter -class RuleListResult(msrest.serialization.Model): +class RuleListResult(_serialization.Model): """The response of the List rule operation. :ivar value: Result of the List Rules operation. @@ -1615,17 +1520,11 @@ class RuleListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Rule]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Rule]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["_models.Rule"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Rule"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: Result of the List Rules operation. :paramtype value: list[~azure.mgmt.servicebus.v2021_01_01_preview.models.Rule] @@ -1633,7 +1532,7 @@ def __init__( list of rules. :paramtype next_link: str """ - super(RuleListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link @@ -1656,36 +1555,31 @@ class SBAuthorizationRule(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'rights': {'key': 'properties.rights', 'type': '[str]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "rights": {"key": "properties.rights", "type": "[str]"}, } - def __init__( - self, - *, - rights: Optional[List[Union[str, "_models.AccessRights"]]] = None, - **kwargs - ): + def __init__(self, *, rights: Optional[List[Union[str, "_models.AccessRights"]]] = None, **kwargs): """ :keyword rights: The rights associated with the rule. :paramtype rights: list[str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.AccessRights] """ - super(SBAuthorizationRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.rights = rights -class SBAuthorizationRuleListResult(msrest.serialization.Model): +class SBAuthorizationRuleListResult(_serialization.Model): """The response to the List Namespace operation. :ivar value: Result of the List Authorization Rules operation. @@ -1696,16 +1590,12 @@ class SBAuthorizationRuleListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[SBAuthorizationRule]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SBAuthorizationRule]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["_models.SBAuthorizationRule"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.SBAuthorizationRule"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Result of the List Authorization Rules operation. @@ -1714,7 +1604,7 @@ def __init__( list of Authorization Rules. :paramtype next_link: str """ - super(SBAuthorizationRuleListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link @@ -1732,46 +1622,40 @@ class TrackedResource(Resource): :vartype name: str :ivar type: Resource type. :vartype type: str - :ivar location: Required. The Geo-location where the resource lives. + :ivar location: The Geo-location where the resource lives. Required. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "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 Geo-location where the resource lives. + :keyword location: The Geo-location where the resource lives. Required. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] """ - super(TrackedResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.tags = tags -class SBNamespace(TrackedResource): +class SBNamespace(TrackedResource): # pylint: disable=too-many-instance-attributes """Description of a namespace resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -1784,9 +1668,9 @@ class SBNamespace(TrackedResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :ivar location: Required. The Geo-location where the resource lives. + :ivar location: The Geo-location where the resource lives. Required. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar sku: Properties of SKU. :vartype sku: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBSku @@ -1817,37 +1701,40 @@ class SBNamespace(TrackedResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'status': {'readonly': True}, - 'created_at': {'readonly': True}, - 'updated_at': {'readonly': True}, - 'service_bus_endpoint': {'readonly': True}, - 'metric_id': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "system_data": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "status": {"readonly": True}, + "created_at": {"readonly": True}, + "updated_at": {"readonly": True}, + "service_bus_endpoint": {"readonly": True}, + "metric_id": {"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}'}, - 'sku': {'key': 'sku', 'type': 'SBSku'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'created_at': {'key': 'properties.createdAt', 'type': 'iso-8601'}, - 'updated_at': {'key': 'properties.updatedAt', 'type': 'iso-8601'}, - 'service_bus_endpoint': {'key': 'properties.serviceBusEndpoint', 'type': 'str'}, - 'metric_id': {'key': 'properties.metricId', 'type': 'str'}, - 'zone_redundant': {'key': 'properties.zoneRedundant', 'type': 'bool'}, - 'encryption': {'key': 'properties.encryption', 'type': 'Encryption'}, - 'private_endpoint_connections': {'key': 'properties.privateEndpointConnections', 'type': '[PrivateEndpointConnection]'}, + "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}"}, + "sku": {"key": "sku", "type": "SBSku"}, + "identity": {"key": "identity", "type": "Identity"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "status": {"key": "properties.status", "type": "str"}, + "created_at": {"key": "properties.createdAt", "type": "iso-8601"}, + "updated_at": {"key": "properties.updatedAt", "type": "iso-8601"}, + "service_bus_endpoint": {"key": "properties.serviceBusEndpoint", "type": "str"}, + "metric_id": {"key": "properties.metricId", "type": "str"}, + "zone_redundant": {"key": "properties.zoneRedundant", "type": "bool"}, + "encryption": {"key": "properties.encryption", "type": "Encryption"}, + "private_endpoint_connections": { + "key": "properties.privateEndpointConnections", + "type": "[PrivateEndpointConnection]", + }, } def __init__( @@ -1863,9 +1750,9 @@ def __init__( **kwargs ): """ - :keyword location: Required. The Geo-location where the resource lives. + :keyword location: The Geo-location where the resource lives. Required. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword sku: Properties of SKU. :paramtype sku: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBSku @@ -1880,7 +1767,7 @@ def __init__( :paramtype private_endpoint_connections: list[~azure.mgmt.servicebus.v2021_01_01_preview.models.PrivateEndpointConnection] """ - super(SBNamespace, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.sku = sku self.identity = identity self.system_data = None @@ -1895,7 +1782,7 @@ def __init__( self.private_endpoint_connections = private_endpoint_connections -class SBNamespaceListResult(msrest.serialization.Model): +class SBNamespaceListResult(_serialization.Model): """The response of the List Namespace operation. :ivar value: Result of the List Namespace operation. @@ -1906,16 +1793,12 @@ class SBNamespaceListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[SBNamespace]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SBNamespace]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["_models.SBNamespace"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.SBNamespace"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Result of the List Namespace operation. @@ -1924,12 +1807,12 @@ def __init__( list of Namespaces. :paramtype next_link: str """ - super(SBNamespaceListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class SBNamespaceUpdateParameters(ResourceNamespacePatch): +class SBNamespaceUpdateParameters(ResourceNamespacePatch): # pylint: disable=too-many-instance-attributes """Description of a namespace resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -1942,7 +1825,7 @@ class SBNamespaceUpdateParameters(ResourceNamespacePatch): :vartype type: str :ivar location: Resource location. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar sku: Properties of SKU. :vartype sku: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBSku @@ -1971,34 +1854,37 @@ class SBNamespaceUpdateParameters(ResourceNamespacePatch): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'status': {'readonly': True}, - 'created_at': {'readonly': True}, - 'updated_at': {'readonly': True}, - 'service_bus_endpoint': {'readonly': True}, - 'metric_id': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "status": {"readonly": True}, + "created_at": {"readonly": True}, + "updated_at": {"readonly": True}, + "service_bus_endpoint": {"readonly": True}, + "metric_id": {"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}'}, - 'sku': {'key': 'sku', 'type': 'SBSku'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'created_at': {'key': 'properties.createdAt', 'type': 'iso-8601'}, - 'updated_at': {'key': 'properties.updatedAt', 'type': 'iso-8601'}, - 'service_bus_endpoint': {'key': 'properties.serviceBusEndpoint', 'type': 'str'}, - 'metric_id': {'key': 'properties.metricId', 'type': 'str'}, - 'zone_redundant': {'key': 'properties.zoneRedundant', 'type': 'bool'}, - 'encryption': {'key': 'properties.encryption', 'type': 'Encryption'}, - 'private_endpoint_connections': {'key': 'properties.privateEndpointConnections', 'type': '[PrivateEndpointConnection]'}, + "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}"}, + "sku": {"key": "sku", "type": "SBSku"}, + "identity": {"key": "identity", "type": "Identity"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "status": {"key": "properties.status", "type": "str"}, + "created_at": {"key": "properties.createdAt", "type": "iso-8601"}, + "updated_at": {"key": "properties.updatedAt", "type": "iso-8601"}, + "service_bus_endpoint": {"key": "properties.serviceBusEndpoint", "type": "str"}, + "metric_id": {"key": "properties.metricId", "type": "str"}, + "zone_redundant": {"key": "properties.zoneRedundant", "type": "bool"}, + "encryption": {"key": "properties.encryption", "type": "Encryption"}, + "private_endpoint_connections": { + "key": "properties.privateEndpointConnections", + "type": "[PrivateEndpointConnection]", + }, } def __init__( @@ -2016,7 +1902,7 @@ def __init__( """ :keyword location: Resource location. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword sku: Properties of SKU. :paramtype sku: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBSku @@ -2031,7 +1917,7 @@ def __init__( :paramtype private_endpoint_connections: list[~azure.mgmt.servicebus.v2021_01_01_preview.models.PrivateEndpointConnection] """ - super(SBNamespaceUpdateParameters, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.sku = sku self.identity = identity self.provisioning_state = None @@ -2045,7 +1931,7 @@ def __init__( self.private_endpoint_connections = private_endpoint_connections -class SBQueue(Resource): +class SBQueue(Resource): # pylint: disable=too-many-instance-attributes """Description of queue Resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -2068,9 +1954,9 @@ class SBQueue(Resource): to this queue. :vartype accessed_at: ~datetime.datetime :ivar size_in_bytes: The size of the queue, in bytes. - :vartype size_in_bytes: long + :vartype size_in_bytes: int :ivar message_count: The number of messages in the queue. - :vartype message_count: long + :vartype message_count: int :ivar lock_duration: ISO 8601 timespan duration of a peek-lock; that is, the amount of time that the message is locked for other receivers. The maximum value for LockDuration is 5 minutes; the default value is 1 minute. @@ -2099,7 +1985,7 @@ class SBQueue(Resource): :vartype max_delivery_count: int :ivar status: Enumerates the possible values for the status of a messaging entity. Known values are: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", "Creating", - "Deleting", "Renaming", "Unknown". + "Deleting", "Renaming", and "Unknown". :vartype status: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.EntityStatus :ivar enable_batched_operations: Value that indicates whether server-side batched operations are enabled. @@ -2120,47 +2006,50 @@ class SBQueue(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'count_details': {'readonly': True}, - 'created_at': {'readonly': True}, - 'updated_at': {'readonly': True}, - 'accessed_at': {'readonly': True}, - 'size_in_bytes': {'readonly': True}, - 'message_count': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "count_details": {"readonly": True}, + "created_at": {"readonly": True}, + "updated_at": {"readonly": True}, + "accessed_at": {"readonly": True}, + "size_in_bytes": {"readonly": True}, + "message_count": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'count_details': {'key': 'properties.countDetails', 'type': 'MessageCountDetails'}, - 'created_at': {'key': 'properties.createdAt', 'type': 'iso-8601'}, - 'updated_at': {'key': 'properties.updatedAt', 'type': 'iso-8601'}, - 'accessed_at': {'key': 'properties.accessedAt', 'type': 'iso-8601'}, - 'size_in_bytes': {'key': 'properties.sizeInBytes', 'type': 'long'}, - 'message_count': {'key': 'properties.messageCount', 'type': 'long'}, - 'lock_duration': {'key': 'properties.lockDuration', 'type': 'duration'}, - 'max_size_in_megabytes': {'key': 'properties.maxSizeInMegabytes', 'type': 'int'}, - 'requires_duplicate_detection': {'key': 'properties.requiresDuplicateDetection', 'type': 'bool'}, - 'requires_session': {'key': 'properties.requiresSession', 'type': 'bool'}, - 'default_message_time_to_live': {'key': 'properties.defaultMessageTimeToLive', 'type': 'duration'}, - 'dead_lettering_on_message_expiration': {'key': 'properties.deadLetteringOnMessageExpiration', 'type': 'bool'}, - 'duplicate_detection_history_time_window': {'key': 'properties.duplicateDetectionHistoryTimeWindow', 'type': 'duration'}, - 'max_delivery_count': {'key': 'properties.maxDeliveryCount', 'type': 'int'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'enable_batched_operations': {'key': 'properties.enableBatchedOperations', 'type': 'bool'}, - 'auto_delete_on_idle': {'key': 'properties.autoDeleteOnIdle', 'type': 'duration'}, - 'enable_partitioning': {'key': 'properties.enablePartitioning', 'type': 'bool'}, - 'enable_express': {'key': 'properties.enableExpress', 'type': 'bool'}, - 'forward_to': {'key': 'properties.forwardTo', 'type': 'str'}, - 'forward_dead_lettered_messages_to': {'key': 'properties.forwardDeadLetteredMessagesTo', 'type': 'str'}, - } - - def __init__( + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "count_details": {"key": "properties.countDetails", "type": "MessageCountDetails"}, + "created_at": {"key": "properties.createdAt", "type": "iso-8601"}, + "updated_at": {"key": "properties.updatedAt", "type": "iso-8601"}, + "accessed_at": {"key": "properties.accessedAt", "type": "iso-8601"}, + "size_in_bytes": {"key": "properties.sizeInBytes", "type": "int"}, + "message_count": {"key": "properties.messageCount", "type": "int"}, + "lock_duration": {"key": "properties.lockDuration", "type": "duration"}, + "max_size_in_megabytes": {"key": "properties.maxSizeInMegabytes", "type": "int"}, + "requires_duplicate_detection": {"key": "properties.requiresDuplicateDetection", "type": "bool"}, + "requires_session": {"key": "properties.requiresSession", "type": "bool"}, + "default_message_time_to_live": {"key": "properties.defaultMessageTimeToLive", "type": "duration"}, + "dead_lettering_on_message_expiration": {"key": "properties.deadLetteringOnMessageExpiration", "type": "bool"}, + "duplicate_detection_history_time_window": { + "key": "properties.duplicateDetectionHistoryTimeWindow", + "type": "duration", + }, + "max_delivery_count": {"key": "properties.maxDeliveryCount", "type": "int"}, + "status": {"key": "properties.status", "type": "str"}, + "enable_batched_operations": {"key": "properties.enableBatchedOperations", "type": "bool"}, + "auto_delete_on_idle": {"key": "properties.autoDeleteOnIdle", "type": "duration"}, + "enable_partitioning": {"key": "properties.enablePartitioning", "type": "bool"}, + "enable_express": {"key": "properties.enableExpress", "type": "bool"}, + "forward_to": {"key": "properties.forwardTo", "type": "str"}, + "forward_dead_lettered_messages_to": {"key": "properties.forwardDeadLetteredMessagesTo", "type": "str"}, + } + + def __init__( # pylint: disable=too-many-locals self, *, lock_duration: Optional[datetime.timedelta] = None, @@ -2209,7 +2098,7 @@ def __init__( :paramtype max_delivery_count: int :keyword status: Enumerates the possible values for the status of a messaging entity. Known values are: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", "Creating", - "Deleting", "Renaming", "Unknown". + "Deleting", "Renaming", and "Unknown". :paramtype status: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.EntityStatus :keyword enable_batched_operations: Value that indicates whether server-side batched operations are enabled. @@ -2229,7 +2118,7 @@ def __init__( message. :paramtype forward_dead_lettered_messages_to: str """ - super(SBQueue, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.count_details = None self.created_at = None @@ -2254,7 +2143,7 @@ def __init__( self.forward_dead_lettered_messages_to = forward_dead_lettered_messages_to -class SBQueueListResult(msrest.serialization.Model): +class SBQueueListResult(_serialization.Model): """The response to the List Queues operation. :ivar value: Result of the List Queues operation. @@ -2265,17 +2154,11 @@ class SBQueueListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[SBQueue]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SBQueue]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["_models.SBQueue"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.SBQueue"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: Result of the List Queues operation. :paramtype value: list[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBQueue] @@ -2283,19 +2166,19 @@ def __init__( list of queues. :paramtype next_link: str """ - super(SBQueueListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class SBSku(msrest.serialization.Model): +class SBSku(_serialization.Model): """SKU of the namespace. All required parameters must be populated in order to send to Azure. - :ivar name: Required. Name of this SKU. Known values are: "Basic", "Standard", "Premium". + :ivar name: Name of this SKU. Required. Known values are: "Basic", "Standard", and "Premium". :vartype name: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.SkuName - :ivar tier: The billing tier of this particular SKU. Known values are: "Basic", "Standard", + :ivar tier: The billing tier of this particular SKU. Known values are: "Basic", "Standard", and "Premium". :vartype tier: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.SkuTier :ivar capacity: The specified messaging units for the tier. For Premium tier, capacity are 1,2 @@ -2304,13 +2187,13 @@ class SBSku(msrest.serialization.Model): """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'capacity': {'key': 'capacity', 'type': 'int'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "capacity": {"key": "capacity", "type": "int"}, } def __init__( @@ -2322,22 +2205,23 @@ def __init__( **kwargs ): """ - :keyword name: Required. Name of this SKU. Known values are: "Basic", "Standard", "Premium". + :keyword name: Name of this SKU. Required. Known values are: "Basic", "Standard", and + "Premium". :paramtype name: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.SkuName :keyword tier: The billing tier of this particular SKU. Known values are: "Basic", "Standard", - "Premium". + and "Premium". :paramtype tier: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.SkuTier :keyword capacity: The specified messaging units for the tier. For Premium tier, capacity are 1,2 and 4. :paramtype capacity: int """ - super(SBSku, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.tier = tier self.capacity = capacity -class SBSubscription(Resource): +class SBSubscription(Resource): # pylint: disable=too-many-instance-attributes """Description of subscription resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -2351,7 +2235,7 @@ class SBSubscription(Resource): :ivar system_data: The system meta data relating to this resource. :vartype system_data: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SystemData :ivar message_count: Number of messages. - :vartype message_count: long + :vartype message_count: int :ivar created_at: Exact time the message was created. :vartype created_at: ~datetime.datetime :ivar accessed_at: Last time there was a receive request to this subscription. @@ -2382,7 +2266,7 @@ class SBSubscription(Resource): :vartype max_delivery_count: int :ivar status: Enumerates the possible values for the status of a messaging entity. Known values are: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", "Creating", - "Deleting", "Renaming", "Unknown". + "Deleting", "Renaming", and "Unknown". :vartype status: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.EntityStatus :ivar enable_batched_operations: Value that indicates whether server-side batched operations are enabled. @@ -2397,39 +2281,45 @@ class SBSubscription(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'message_count': {'readonly': True}, - 'created_at': {'readonly': True}, - 'accessed_at': {'readonly': True}, - 'updated_at': {'readonly': True}, - 'count_details': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "message_count": {"readonly": True}, + "created_at": {"readonly": True}, + "accessed_at": {"readonly": True}, + "updated_at": {"readonly": True}, + "count_details": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'message_count': {'key': 'properties.messageCount', 'type': 'long'}, - 'created_at': {'key': 'properties.createdAt', 'type': 'iso-8601'}, - 'accessed_at': {'key': 'properties.accessedAt', 'type': 'iso-8601'}, - 'updated_at': {'key': 'properties.updatedAt', 'type': 'iso-8601'}, - 'count_details': {'key': 'properties.countDetails', 'type': 'MessageCountDetails'}, - 'lock_duration': {'key': 'properties.lockDuration', 'type': 'duration'}, - 'requires_session': {'key': 'properties.requiresSession', 'type': 'bool'}, - 'default_message_time_to_live': {'key': 'properties.defaultMessageTimeToLive', 'type': 'duration'}, - 'dead_lettering_on_filter_evaluation_exceptions': {'key': 'properties.deadLetteringOnFilterEvaluationExceptions', 'type': 'bool'}, - 'dead_lettering_on_message_expiration': {'key': 'properties.deadLetteringOnMessageExpiration', 'type': 'bool'}, - 'duplicate_detection_history_time_window': {'key': 'properties.duplicateDetectionHistoryTimeWindow', 'type': 'duration'}, - 'max_delivery_count': {'key': 'properties.maxDeliveryCount', 'type': 'int'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'enable_batched_operations': {'key': 'properties.enableBatchedOperations', 'type': 'bool'}, - 'auto_delete_on_idle': {'key': 'properties.autoDeleteOnIdle', 'type': 'duration'}, - 'forward_to': {'key': 'properties.forwardTo', 'type': 'str'}, - 'forward_dead_lettered_messages_to': {'key': 'properties.forwardDeadLetteredMessagesTo', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "message_count": {"key": "properties.messageCount", "type": "int"}, + "created_at": {"key": "properties.createdAt", "type": "iso-8601"}, + "accessed_at": {"key": "properties.accessedAt", "type": "iso-8601"}, + "updated_at": {"key": "properties.updatedAt", "type": "iso-8601"}, + "count_details": {"key": "properties.countDetails", "type": "MessageCountDetails"}, + "lock_duration": {"key": "properties.lockDuration", "type": "duration"}, + "requires_session": {"key": "properties.requiresSession", "type": "bool"}, + "default_message_time_to_live": {"key": "properties.defaultMessageTimeToLive", "type": "duration"}, + "dead_lettering_on_filter_evaluation_exceptions": { + "key": "properties.deadLetteringOnFilterEvaluationExceptions", + "type": "bool", + }, + "dead_lettering_on_message_expiration": {"key": "properties.deadLetteringOnMessageExpiration", "type": "bool"}, + "duplicate_detection_history_time_window": { + "key": "properties.duplicateDetectionHistoryTimeWindow", + "type": "duration", + }, + "max_delivery_count": {"key": "properties.maxDeliveryCount", "type": "int"}, + "status": {"key": "properties.status", "type": "str"}, + "enable_batched_operations": {"key": "properties.enableBatchedOperations", "type": "bool"}, + "auto_delete_on_idle": {"key": "properties.autoDeleteOnIdle", "type": "duration"}, + "forward_to": {"key": "properties.forwardTo", "type": "str"}, + "forward_dead_lettered_messages_to": {"key": "properties.forwardDeadLetteredMessagesTo", "type": "str"}, } def __init__( @@ -2472,7 +2362,7 @@ def __init__( :paramtype max_delivery_count: int :keyword status: Enumerates the possible values for the status of a messaging entity. Known values are: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", "Creating", - "Deleting", "Renaming", "Unknown". + "Deleting", "Renaming", and "Unknown". :paramtype status: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.EntityStatus :keyword enable_batched_operations: Value that indicates whether server-side batched operations are enabled. @@ -2486,7 +2376,7 @@ def __init__( message. :paramtype forward_dead_lettered_messages_to: str """ - super(SBSubscription, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.message_count = None self.created_at = None @@ -2507,7 +2397,7 @@ def __init__( self.forward_dead_lettered_messages_to = forward_dead_lettered_messages_to -class SBSubscriptionListResult(msrest.serialization.Model): +class SBSubscriptionListResult(_serialization.Model): """The response to the List Subscriptions operation. :ivar value: Result of the List Subscriptions operation. @@ -2518,16 +2408,12 @@ class SBSubscriptionListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[SBSubscription]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SBSubscription]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["_models.SBSubscription"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.SBSubscription"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Result of the List Subscriptions operation. @@ -2536,12 +2422,12 @@ def __init__( list of subscriptions. :paramtype next_link: str """ - super(SBSubscriptionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class SBTopic(Resource): +class SBTopic(Resource): # pylint: disable=too-many-instance-attributes """Description of topic resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -2555,7 +2441,7 @@ class SBTopic(Resource): :ivar system_data: The system meta data relating to this resource. :vartype system_data: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SystemData :ivar size_in_bytes: Size of the topic, in bytes. - :vartype size_in_bytes: long + :vartype size_in_bytes: int :ivar created_at: Exact time the message was created. :vartype created_at: ~datetime.datetime :ivar updated_at: The exact time the message was updated. @@ -2584,7 +2470,7 @@ class SBTopic(Resource): :vartype enable_batched_operations: bool :ivar status: Enumerates the possible values for the status of a messaging entity. Known values are: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", "Creating", - "Deleting", "Renaming", "Unknown". + "Deleting", "Renaming", and "Unknown". :vartype status: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.EntityStatus :ivar support_ordering: Value that indicates whether the topic supports ordering. :vartype support_ordering: bool @@ -2600,39 +2486,42 @@ class SBTopic(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'size_in_bytes': {'readonly': True}, - 'created_at': {'readonly': True}, - 'updated_at': {'readonly': True}, - 'accessed_at': {'readonly': True}, - 'subscription_count': {'readonly': True}, - 'count_details': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "size_in_bytes": {"readonly": True}, + "created_at": {"readonly": True}, + "updated_at": {"readonly": True}, + "accessed_at": {"readonly": True}, + "subscription_count": {"readonly": True}, + "count_details": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'size_in_bytes': {'key': 'properties.sizeInBytes', 'type': 'long'}, - 'created_at': {'key': 'properties.createdAt', 'type': 'iso-8601'}, - 'updated_at': {'key': 'properties.updatedAt', 'type': 'iso-8601'}, - 'accessed_at': {'key': 'properties.accessedAt', 'type': 'iso-8601'}, - 'subscription_count': {'key': 'properties.subscriptionCount', 'type': 'int'}, - 'count_details': {'key': 'properties.countDetails', 'type': 'MessageCountDetails'}, - 'default_message_time_to_live': {'key': 'properties.defaultMessageTimeToLive', 'type': 'duration'}, - 'max_size_in_megabytes': {'key': 'properties.maxSizeInMegabytes', 'type': 'int'}, - 'requires_duplicate_detection': {'key': 'properties.requiresDuplicateDetection', 'type': 'bool'}, - 'duplicate_detection_history_time_window': {'key': 'properties.duplicateDetectionHistoryTimeWindow', 'type': 'duration'}, - 'enable_batched_operations': {'key': 'properties.enableBatchedOperations', 'type': 'bool'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'support_ordering': {'key': 'properties.supportOrdering', 'type': 'bool'}, - 'auto_delete_on_idle': {'key': 'properties.autoDeleteOnIdle', 'type': 'duration'}, - 'enable_partitioning': {'key': 'properties.enablePartitioning', 'type': 'bool'}, - 'enable_express': {'key': 'properties.enableExpress', 'type': 'bool'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "size_in_bytes": {"key": "properties.sizeInBytes", "type": "int"}, + "created_at": {"key": "properties.createdAt", "type": "iso-8601"}, + "updated_at": {"key": "properties.updatedAt", "type": "iso-8601"}, + "accessed_at": {"key": "properties.accessedAt", "type": "iso-8601"}, + "subscription_count": {"key": "properties.subscriptionCount", "type": "int"}, + "count_details": {"key": "properties.countDetails", "type": "MessageCountDetails"}, + "default_message_time_to_live": {"key": "properties.defaultMessageTimeToLive", "type": "duration"}, + "max_size_in_megabytes": {"key": "properties.maxSizeInMegabytes", "type": "int"}, + "requires_duplicate_detection": {"key": "properties.requiresDuplicateDetection", "type": "bool"}, + "duplicate_detection_history_time_window": { + "key": "properties.duplicateDetectionHistoryTimeWindow", + "type": "duration", + }, + "enable_batched_operations": {"key": "properties.enableBatchedOperations", "type": "bool"}, + "status": {"key": "properties.status", "type": "str"}, + "support_ordering": {"key": "properties.supportOrdering", "type": "bool"}, + "auto_delete_on_idle": {"key": "properties.autoDeleteOnIdle", "type": "duration"}, + "enable_partitioning": {"key": "properties.enablePartitioning", "type": "bool"}, + "enable_express": {"key": "properties.enableExpress", "type": "bool"}, } def __init__( @@ -2669,7 +2558,7 @@ def __init__( :paramtype enable_batched_operations: bool :keyword status: Enumerates the possible values for the status of a messaging entity. Known values are: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", "Creating", - "Deleting", "Renaming", "Unknown". + "Deleting", "Renaming", and "Unknown". :paramtype status: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.EntityStatus :keyword support_ordering: Value that indicates whether the topic supports ordering. :paramtype support_ordering: bool @@ -2683,7 +2572,7 @@ def __init__( topic holds a message in memory temporarily before writing it to persistent storage. :paramtype enable_express: bool """ - super(SBTopic, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.size_in_bytes = None self.created_at = None @@ -2703,7 +2592,7 @@ def __init__( self.enable_express = enable_express -class SBTopicListResult(msrest.serialization.Model): +class SBTopicListResult(_serialization.Model): """The response to the List Topics operation. :ivar value: Result of the List Topics operation. @@ -2714,17 +2603,11 @@ class SBTopicListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[SBTopic]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SBTopic]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["_models.SBTopic"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.SBTopic"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: Result of the List Topics operation. :paramtype value: list[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBTopic] @@ -2732,12 +2615,12 @@ def __init__( list of topics. :paramtype next_link: str """ - super(SBTopicListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class SqlFilter(msrest.serialization.Model): +class SqlFilter(_serialization.Model): """Represents a filter which is a composition of an expression and an action that is executed in the pub/sub pipeline. :ivar sql_expression: The SQL expression. e.g. MyProperty='ABC'. @@ -2751,21 +2634,21 @@ class SqlFilter(msrest.serialization.Model): """ _validation = { - 'compatibility_level': {'maximum': 20, 'minimum': 20}, + "compatibility_level": {"maximum": 20, "minimum": 20}, } _attribute_map = { - 'sql_expression': {'key': 'sqlExpression', 'type': 'str'}, - 'compatibility_level': {'key': 'compatibilityLevel', 'type': 'int'}, - 'requires_preprocessing': {'key': 'requiresPreprocessing', 'type': 'bool'}, + "sql_expression": {"key": "sqlExpression", "type": "str"}, + "compatibility_level": {"key": "compatibilityLevel", "type": "int"}, + "requires_preprocessing": {"key": "requiresPreprocessing", "type": "bool"}, } def __init__( self, *, sql_expression: Optional[str] = None, - compatibility_level: Optional[int] = 20, - requires_preprocessing: Optional[bool] = True, + compatibility_level: int = 20, + requires_preprocessing: bool = True, **kwargs ): """ @@ -2778,7 +2661,7 @@ def __init__( preprocessing. :paramtype requires_preprocessing: bool """ - super(SqlFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.sql_expression = sql_expression self.compatibility_level = compatibility_level self.requires_preprocessing = requires_preprocessing @@ -2798,9 +2681,9 @@ class SqlRuleAction(Action): """ _attribute_map = { - 'sql_expression': {'key': 'sqlExpression', 'type': 'str'}, - 'compatibility_level': {'key': 'compatibilityLevel', 'type': 'int'}, - 'requires_preprocessing': {'key': 'requiresPreprocessing', 'type': 'bool'}, + "sql_expression": {"key": "sqlExpression", "type": "str"}, + "compatibility_level": {"key": "compatibilityLevel", "type": "int"}, + "requires_preprocessing": {"key": "requiresPreprocessing", "type": "bool"}, } def __init__( @@ -2808,7 +2691,7 @@ def __init__( *, sql_expression: Optional[str] = None, compatibility_level: Optional[int] = None, - requires_preprocessing: Optional[bool] = True, + requires_preprocessing: bool = True, **kwargs ): """ @@ -2821,47 +2704,47 @@ def __init__( preprocessing. :paramtype requires_preprocessing: bool """ - super(SqlRuleAction, self).__init__(sql_expression=sql_expression, compatibility_level=compatibility_level, requires_preprocessing=requires_preprocessing, **kwargs) + super().__init__( + sql_expression=sql_expression, + compatibility_level=compatibility_level, + requires_preprocessing=requires_preprocessing, + **kwargs + ) -class Subnet(msrest.serialization.Model): +class Subnet(_serialization.Model): """Properties supplied for Subnet. All required parameters must be populated in order to send to Azure. - :ivar id: Required. Resource ID of Virtual Network Subnet. + :ivar id: Resource ID of Virtual Network Subnet. Required. :vartype id: str """ _validation = { - 'id': {'required': True}, + "id": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - *, - id: str, - **kwargs - ): + def __init__(self, *, id: str, **kwargs): # pylint: disable=redefined-builtin """ - :keyword id: Required. Resource ID of Virtual Network Subnet. + :keyword id: Resource ID of Virtual Network Subnet. Required. :paramtype id: str """ - super(Subnet, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id -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. Known values are: - "User", "Application", "ManagedIdentity", "Key". + "User", "Application", "ManagedIdentity", and "Key". :vartype created_by_type: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.CreatedByType :ivar created_at: The timestamp of resource creation (UTC). @@ -2869,7 +2752,7 @@ class SystemData(msrest.serialization.Model): :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", "Key". + are: "User", "Application", "ManagedIdentity", and "Key". :vartype last_modified_by_type: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.CreatedByType :ivar last_modified_at: The type of identity that last modified the resource. @@ -2877,12 +2760,12 @@ class SystemData(msrest.serialization.Model): """ _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__( @@ -2900,7 +2783,7 @@ def __init__( :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", "Key". + "User", "Application", "ManagedIdentity", and "Key". :paramtype created_by_type: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.CreatedByType :keyword created_at: The timestamp of resource creation (UTC). @@ -2908,13 +2791,13 @@ def __init__( :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", "Key". + values are: "User", "Application", "ManagedIdentity", and "Key". :paramtype last_modified_by_type: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.CreatedByType :keyword last_modified_at: The type of identity that last modified the resource. :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 @@ -2923,7 +2806,7 @@ def __init__( self.last_modified_at = last_modified_at -class UserAssignedIdentityProperties(msrest.serialization.Model): +class UserAssignedIdentityProperties(_serialization.Model): """UserAssignedIdentityProperties. :ivar user_assigned_identity: ARM ID of user Identity selected for encryption. @@ -2931,18 +2814,13 @@ class UserAssignedIdentityProperties(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: ARM ID of user Identity selected for encryption. :paramtype user_assigned_identity: str """ - super(UserAssignedIdentityProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.user_assigned_identity = user_assigned_identity diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/models/_patch.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/models/_patch.py index 0ad201a8c586e..f7dd32510333d 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/models/_patch.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/models/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/models/_service_bus_management_client_enums.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/models/_service_bus_management_client_enums.py index 6fa98eab2bd79..4eff4b68262a4 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/models/_service_bus_management_client_enums.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/models/_service_bus_management_client_enums.py @@ -11,30 +11,31 @@ class AccessRights(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """AccessRights.""" MANAGE = "Manage" SEND = "Send" LISTEN = "Listen" + class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of identity that created the resource. - """ + """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 - """ + """Default Action for Network Rule Set.""" ALLOW = "Allow" DENY = "Deny" + class EndPointProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Provisioning state of the Private Endpoint Connection. - """ + """Provisioning state of the Private Endpoint Connection.""" CREATING = "Creating" UPDATING = "Updating" @@ -43,9 +44,9 @@ class EndPointProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): CANCELED = "Canceled" FAILED = "Failed" + class EntityStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Entity status. - """ + """Entity status.""" ACTIVE = "Active" DISABLED = "Disabled" @@ -57,85 +58,89 @@ class EntityStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): RENAMING = "Renaming" UNKNOWN = "Unknown" + class FilterType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Rule filter types - """ + """Rule filter types.""" SQL_FILTER = "SqlFilter" CORRELATION_FILTER = "CorrelationFilter" + class KeyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The access key to regenerate. - """ + """The access key to regenerate.""" PRIMARY_KEY = "PrimaryKey" SECONDARY_KEY = "SecondaryKey" + class ManagedServiceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Type of managed service identity. - """ + """Type of managed service identity.""" SYSTEM_ASSIGNED = "SystemAssigned" USER_ASSIGNED = "UserAssigned" SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" NONE = "None" + class MigrationConfigurationName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """MigrationConfigurationName.""" _DEFAULT = "$default" + class NetworkRuleIPAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The IP Filter Action - """ + """The IP Filter Action.""" ALLOW = "Allow" + class PrivateLinkConnectionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Status of the connection. - """ + """Status of the connection.""" PENDING = "Pending" APPROVED = "Approved" REJECTED = "Rejected" DISCONNECTED = "Disconnected" + class ProvisioningStateDR(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Provisioning state of the Alias(Disaster Recovery configuration) - possible values 'Accepted' - or 'Succeeded' or 'Failed' + or 'Succeeded' or 'Failed'. """ ACCEPTED = "Accepted" SUCCEEDED = "Succeeded" FAILED = "Failed" + class RoleDisasterRecovery(str, Enum, metaclass=CaseInsensitiveEnumMeta): """role of namespace in GEO DR - possible values 'Primary' or 'PrimaryNotReplicating' or - 'Secondary' + 'Secondary'. """ PRIMARY = "Primary" PRIMARY_NOT_REPLICATING = "PrimaryNotReplicating" SECONDARY = "Secondary" + class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Name of this SKU. - """ + """Name of this SKU.""" BASIC = "Basic" STANDARD = "Standard" PREMIUM = "Premium" + class SkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The billing tier of this particular SKU. - """ + """The billing tier of this particular SKU.""" BASIC = "Basic" STANDARD = "Standard" PREMIUM = "Premium" + class UnavailableReason(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the reason for the unavailability of the service. - """ + """Specifies the reason for the unavailability of the service.""" NONE = "None" INVALID_NAME = "InvalidName" diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/operations/__init__.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/operations/__init__.py index 5559ccd3746c6..e5431803c533c 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/operations/__init__.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/operations/__init__.py @@ -18,19 +18,20 @@ from ._subscriptions_operations import SubscriptionsOperations from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'NamespacesOperations', - 'PrivateEndpointConnectionsOperations', - 'PrivateLinkResourcesOperations', - 'Operations', - 'DisasterRecoveryConfigsOperations', - 'MigrationConfigsOperations', - 'QueuesOperations', - 'TopicsOperations', - 'RulesOperations', - 'SubscriptionsOperations', + "NamespacesOperations", + "PrivateEndpointConnectionsOperations", + "PrivateLinkResourcesOperations", + "Operations", + "DisasterRecoveryConfigsOperations", + "MigrationConfigsOperations", + "QueuesOperations", + "TopicsOperations", + "RulesOperations", + "SubscriptionsOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/operations/_disaster_recovery_configs_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/operations/_disaster_recovery_configs_operations.py index 58c06a3153797..31b30afd22bd1 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/operations/_disaster_recovery_configs_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/operations/_disaster_recovery_configs_operations.py @@ -6,11 +6,18 @@ # 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 msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,343 +27,313 @@ 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') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_check_name_availability_request( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - *, - json: Optional[_models.CheckNameAvailability] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_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-01-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: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/CheckNameAvailability") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/CheckNameAvailability", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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, - 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_request( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_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-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _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, - namespace_name: str, - alias: str, - subscription_id: str, - *, - json: Optional[_models.ArmDisasterRecovery] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_name: str, alias: 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-01-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: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "alias": _SERIALIZER.url("alias", alias, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "alias": _SERIALIZER.url("alias", alias, "str", max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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, - 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( - resource_group_name: str, - namespace_name: str, - alias: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, alias: 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-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "alias": _SERIALIZER.url("alias", alias, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "alias": _SERIALIZER.url("alias", alias, "str", max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - namespace_name: str, - alias: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, alias: 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-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "alias": _SERIALIZER.url("alias", alias, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "alias": _SERIALIZER.url("alias", alias, "str", max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_break_pairing_request( - resource_group_name: str, - namespace_name: str, - alias: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, alias: 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-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/breakPairing") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/breakPairing", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "alias": _SERIALIZER.url("alias", alias, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "alias": _SERIALIZER.url("alias", alias, "str", max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_fail_over_request( - resource_group_name: str, - namespace_name: str, - alias: str, - subscription_id: str, - *, - json: Optional[_models.FailoverProperties] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_name: str, alias: 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-01-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: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/failover") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/failover", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "alias": _SERIALIZER.url("alias", alias, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "alias": _SERIALIZER.url("alias", alias, "str", max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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, - 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_authorization_rules_request( - resource_group_name: str, - namespace_name: str, - alias: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, alias: 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-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "alias": _SERIALIZER.url("alias", alias, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "alias": _SERIALIZER.url("alias", alias, "str", max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_authorization_rule_request( @@ -370,34 +347,37 @@ def build_get_authorization_rule_request( _headers = case_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-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules/{authorizationRuleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "alias": _SERIALIZER.url("alias", alias, 'str', max_length=50, min_length=1), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "alias": _SERIALIZER.url("alias", alias, "str", max_length=50, min_length=1), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_keys_request( @@ -411,34 +391,38 @@ def build_list_keys_request( _headers = case_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-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules/{authorizationRuleName}/listKeys") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules/{authorizationRuleName}/listKeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "alias": _SERIALIZER.url("alias", alias, 'str', max_length=50, min_length=1), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "alias": _SERIALIZER.url("alias", alias, "str", max_length=50, min_length=1), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + class DisasterRecoveryConfigsOperations: """ @@ -459,41 +443,109 @@ def __init__(self, *args, **kwargs): 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 + @overload def check_name_availability( self, resource_group_name: str, namespace_name: str, parameters: _models.CheckNameAvailability, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Check the give namespace name availability. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: Parameters to check availability of the given namespace name. + :param parameters: Parameters to check availability of the given namespace name. Required. :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.CheckNameAvailability + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckNameAvailabilityResult or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters to check availability of the given namespace name. Required. + :type 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: CheckNameAvailabilityResult or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_name_availability( + self, + resource_group_name: str, + namespace_name: str, + parameters: Union[_models.CheckNameAvailability, IO], + **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters to check availability of the given namespace name. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.CheckNameAvailability 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: CheckNameAvailabilityResult, or the result of cls(response) + :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.CheckNameAvailabilityResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.CheckNameAvailabilityResult] - - _json = self._serialize.body(parameters, 'CheckNameAvailability') + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CheckNameAvailabilityResult] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "CheckNameAvailability") request = build_check_name_availability_request( resource_group_name=resource_group_name, @@ -502,18 +554,18 @@ def check_name_availability( 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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -521,74 +573,79 @@ def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) + deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/CheckNameAvailability"} # type: ignore - + check_name_availability.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/CheckNameAvailability" + } @distributed_trace def list( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> Iterable[_models.ArmDisasterRecoveryListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> Iterable["_models.ArmDisasterRecovery"]: """Gets all Alias(Disaster Recovery configurations). - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ArmDisasterRecoveryListResult or the result of - cls(response) + :return: An iterator like instance of either ArmDisasterRecovery or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.ArmDisasterRecoveryListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.ArmDisasterRecovery] + :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', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ArmDisasterRecoveryListResult] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + cls: ClsType[_models.ArmDisasterRecoveryListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -596,16 +653,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("ArmDisasterRecoveryListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -616,49 +671,126 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs" + } - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, namespace_name: str, alias: str, parameters: _models.ArmDisasterRecovery, + *, + content_type: str = "application/json", **kwargs: Any ) -> Optional[_models.ArmDisasterRecovery]: """Creates or updates a new Alias(Disaster Recovery configuration). - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: str :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). + Required. :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.ArmDisasterRecovery + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ArmDisasterRecovery, or the result of cls(response) + :return: ArmDisasterRecovery or None or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.ArmDisasterRecovery or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + alias: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> Optional[_models.ArmDisasterRecovery]: + """Creates or updates a new Alias(Disaster Recovery configuration). + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: str + :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). + Required. + :type 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: ArmDisasterRecovery or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.ArmDisasterRecovery or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + alias: str, + parameters: Union[_models.ArmDisasterRecovery, IO], + **kwargs: Any + ) -> Optional[_models.ArmDisasterRecovery]: + """Creates or updates a new Alias(Disaster Recovery configuration). + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: str + :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). Is + either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.ArmDisasterRecovery 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: ArmDisasterRecovery or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.ArmDisasterRecovery or None + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ArmDisasterRecovery]] - - _json = self._serialize.body(parameters, 'ArmDisasterRecovery') + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.ArmDisasterRecovery]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ArmDisasterRecovery") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -668,18 +800,18 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - 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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -689,67 +821,67 @@ def create_or_update( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ArmDisasterRecovery', pipeline_response) + deserialized = self._deserialize("ArmDisasterRecovery", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}"} # type: ignore - + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}" + } @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - alias: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, alias: str, **kwargs: Any ) -> None: """Deletes an Alias(Disaster Recovery configuration). - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: 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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, alias=alias, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -760,60 +892,60 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}"} # type: ignore - + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}" + } @distributed_trace def get( - self, - resource_group_name: str, - namespace_name: str, - alias: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, alias: str, **kwargs: Any ) -> _models.ArmDisasterRecovery: """Retrieves Alias(Disaster Recovery configuration) for primary or secondary namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ArmDisasterRecovery, or the result of cls(response) + :return: ArmDisasterRecovery or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.ArmDisasterRecovery - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ArmDisasterRecovery] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + cls: ClsType[_models.ArmDisasterRecovery] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, alias=alias, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -821,68 +953,68 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ArmDisasterRecovery', pipeline_response) + deserialized = self._deserialize("ArmDisasterRecovery", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}" + } @distributed_trace def break_pairing( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - alias: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, alias: str, **kwargs: Any ) -> None: """This operation disables the Disaster Recovery and stops replicating changes from primary to secondary namespaces. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: 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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_break_pairing_request( resource_group_name=resource_group_name, namespace_name=namespace_name, alias=alias, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.break_pairing.metadata['url'], + template_url=self.break_pairing.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -893,50 +1025,127 @@ def break_pairing( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - break_pairing.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/breakPairing"} # type: ignore - + break_pairing.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/breakPairing" + } - @distributed_trace + @overload def fail_over( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, alias: str, parameters: Optional[_models.FailoverProperties] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> None: """Invokes GEO DR failover and reconfigure the alias to point to the secondary namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: str :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). Default value is None. :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.FailoverProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default 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: + """ + + @overload + def fail_over( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + namespace_name: str, + alias: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Invokes GEO DR failover and reconfigure the alias to point to the secondary namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: str + :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). + Default value is None. + :type 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: 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: + """ + + @distributed_trace + def fail_over( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + namespace_name: str, + alias: str, + parameters: Optional[Union[_models.FailoverProperties, IO]] = None, + **kwargs: Any + ) -> None: + """Invokes GEO DR failover and reconfigure the alias to point to the secondary namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: str + :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). Is + either a model type or a IO type. Default value is None. + :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.FailoverProperties 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: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[None] - - if parameters is not None: - _json = self._serialize.body(parameters, 'FailoverProperties') + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "FailoverProperties") + else: + _json = None request = build_fail_over_request( resource_group_name=resource_group_name, @@ -946,18 +1155,18 @@ def fail_over( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, json=_json, - template_url=self.fail_over.metadata['url'], + content=_content, + template_url=self.fail_over.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -968,72 +1177,75 @@ def fail_over( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - fail_over.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/failover"} # type: ignore - + fail_over.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/failover" + } @distributed_trace def list_authorization_rules( - self, - resource_group_name: str, - namespace_name: str, - alias: str, - **kwargs: Any - ) -> Iterable[_models.SBAuthorizationRuleListResult]: + self, resource_group_name: str, namespace_name: str, alias: str, **kwargs: Any + ) -> Iterable["_models.SBAuthorizationRule"]: """Gets the authorization rules for a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of - cls(response) + :return: An iterator like instance of either SBAuthorizationRule or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRule] + :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', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRuleListResult] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + cls: ClsType[_models.SBAuthorizationRuleListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_authorization_rules_request( resource_group_name=resource_group_name, namespace_name=namespace_name, alias=alias, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_authorization_rules.metadata['url'], + template_url=self.list_authorization_rules.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_authorization_rules_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - alias=alias, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -1041,16 +1253,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("SBAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1061,48 +1271,47 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_authorization_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules"} # type: ignore + list_authorization_rules.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules" + } @distributed_trace def get_authorization_rule( - self, - resource_group_name: str, - namespace_name: str, - alias: str, - authorization_rule_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, alias: str, authorization_rule_name: str, **kwargs: Any ) -> _models.SBAuthorizationRule: """Gets an authorization rule for a namespace by rule name. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + cls: ClsType[_models.SBAuthorizationRule] = kwargs.pop("cls", None) - request = build_get_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -1110,18 +1319,17 @@ def get_authorization_rule( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_authorization_rule.metadata['url'], + template_url=self.get_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1129,52 +1337,52 @@ def get_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules/{authorizationRuleName}"} # type: ignore - + get_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules/{authorizationRuleName}" + } @distributed_trace def list_keys( - self, - resource_group_name: str, - namespace_name: str, - alias: str, - authorization_rule_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, alias: str, authorization_rule_name: str, **kwargs: Any ) -> _models.AccessKeys: """Gets the primary and secondary connection strings for the namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + cls: ClsType[_models.AccessKeys] = kwargs.pop("cls", None) - request = build_list_keys_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -1182,18 +1390,17 @@ def list_keys( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata['url'], + 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 + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1201,12 +1408,13 @@ def list_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + deserialized = self._deserialize("AccessKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules/{authorizationRuleName}/listKeys"} # type: ignore - + list_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules/{authorizationRuleName}/listKeys" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/operations/_migration_configs_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/operations/_migration_configs_operations.py index 0f1c90d3644dd..314c9b7fca44a 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/operations/_migration_configs_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/operations/_migration_configs_operations.py @@ -6,11 +6,18 @@ # 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, Union, cast - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -22,251 +29,257 @@ 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') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +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, - namespace_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_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-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_and_start_migration_request_initial( +def build_create_and_start_migration_request( resource_group_name: str, namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], + config_name: Union[str, _models.MigrationConfigurationName], subscription_id: str, - *, - json: Optional[_models.MigrationConfigProperties] = None, - content: Any = 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', "2021-01-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: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "configName": _SERIALIZER.url("config_name", config_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "configName": _SERIALIZER.url("config_name", config_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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, - 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( resource_group_name: str, namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], + config_name: Union[str, _models.MigrationConfigurationName], 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-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "configName": _SERIALIZER.url("config_name", config_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "configName": _SERIALIZER.url("config_name", config_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( resource_group_name: str, namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], + config_name: Union[str, _models.MigrationConfigurationName], 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-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "configName": _SERIALIZER.url("config_name", config_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "configName": _SERIALIZER.url("config_name", config_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_complete_migration_request( resource_group_name: str, namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], + config_name: Union[str, _models.MigrationConfigurationName], 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-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/upgrade") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/upgrade", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "configName": _SERIALIZER.url("config_name", config_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "configName": _SERIALIZER.url("config_name", config_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_revert_request( resource_group_name: str, namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], + config_name: Union[str, _models.MigrationConfigurationName], 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-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/revert") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/revert", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "configName": _SERIALIZER.url("config_name", config_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "configName": _SERIALIZER.url("config_name", config_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + class MigrationConfigsOperations: """ @@ -287,65 +300,69 @@ def __init__(self, *args, **kwargs): 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, - namespace_name: str, - **kwargs: Any - ) -> Iterable[_models.MigrationConfigListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> Iterable["_models.MigrationConfigProperties"]: """Gets all migrationConfigurations. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MigrationConfigListResult or the result of + :return: An iterator like instance of either MigrationConfigProperties or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.MigrationConfigListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.MigrationConfigProperties] + :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', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MigrationConfigListResult] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + cls: ClsType[_models.MigrationConfigListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -353,16 +370,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("MigrationConfigListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -373,35 +388,46 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations" + } def _create_and_start_migration_initial( self, resource_group_name: str, namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], - parameters: _models.MigrationConfigProperties, + config_name: Union[str, _models.MigrationConfigurationName], + parameters: Union[_models.MigrationConfigProperties, IO], **kwargs: Any ) -> Optional[_models.MigrationConfigProperties]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.MigrationConfigProperties]] - - _json = self._serialize.body(parameters, 'MigrationConfigProperties') - - request = build_create_and_start_migration_request_initial( + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.MigrationConfigProperties]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "MigrationConfigProperties") + + request = build_create_and_start_migration_request( resource_group_name=resource_group_name, namespace_name=namespace_name, config_name=config_name, @@ -409,57 +435,146 @@ def _create_and_start_migration_initial( api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_and_start_migration_initial.metadata['url'], + content=_content, + template_url=self._create_and_start_migration_initial.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('MigrationConfigProperties', pipeline_response) + deserialized = self._deserialize("MigrationConfigProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_and_start_migration_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}"} # type: ignore + _create_and_start_migration_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}" + } + @overload + def begin_create_and_start_migration( + self, + resource_group_name: str, + namespace_name: str, + config_name: Union[str, _models.MigrationConfigurationName], + parameters: _models.MigrationConfigProperties, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.MigrationConfigProperties]: + """Creates Migration configuration and starts migration of entities from Standard to Premium + namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param config_name: The configuration name. Should always be "$default". "$default" Required. + :type config_name: str or + ~azure.mgmt.servicebus.v2021_01_01_preview.models.MigrationConfigurationName + :param parameters: Parameters required to create Migration Configuration. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.MigrationConfigProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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 MigrationConfigProperties or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.servicebus.v2021_01_01_preview.models.MigrationConfigProperties] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_and_start_migration( + self, + resource_group_name: str, + namespace_name: str, + config_name: Union[str, _models.MigrationConfigurationName], + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.MigrationConfigProperties]: + """Creates Migration configuration and starts migration of entities from Standard to Premium + namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param config_name: The configuration name. Should always be "$default". "$default" Required. + :type config_name: str or + ~azure.mgmt.servicebus.v2021_01_01_preview.models.MigrationConfigurationName + :param parameters: Parameters required to create Migration Configuration. Required. + :type 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 + :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 MigrationConfigProperties or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.servicebus.v2021_01_01_preview.models.MigrationConfigProperties] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_and_start_migration( self, resource_group_name: str, namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], - parameters: _models.MigrationConfigProperties, + config_name: Union[str, _models.MigrationConfigurationName], + parameters: Union[_models.MigrationConfigProperties, IO], **kwargs: Any ) -> LROPoller[_models.MigrationConfigProperties]: """Creates Migration configuration and starts migration of entities from Standard to Premium namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :type config_name: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.MigrationConfigurationName - :param parameters: Parameters required to create Migration Configuration. + :param parameters: Parameters required to create Migration Configuration. Is either a model + type or a IO type. Required. :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.MigrationConfigProperties + 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 @@ -472,114 +587,114 @@ def begin_create_and_start_migration( of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.servicebus.v2021_01_01_preview.models.MigrationConfigProperties] - :raises: ~azure.core.exceptions.HttpResponseError + :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-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.MigrationConfigProperties] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.MigrationConfigProperties] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._create_and_start_migration_initial( # type: ignore + raw_result = self._create_and_start_migration_initial( resource_group_name=resource_group_name, namespace_name=namespace_name, config_name=config_name, parameters=parameters, 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): - deserialized = self._deserialize('MigrationConfigProperties', pipeline_response) + deserialized = self._deserialize("MigrationConfigProperties", 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 + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create_and_start_migration.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}"} # type: ignore + begin_create_and_start_migration.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}" + } @distributed_trace def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], + config_name: Union[str, _models.MigrationConfigurationName], **kwargs: Any ) -> None: """Deletes a MigrationConfiguration. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :type config_name: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.MigrationConfigurationName :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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, config_name=config_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -590,61 +705,65 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}"} # type: ignore - + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}" + } @distributed_trace def get( self, resource_group_name: str, namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], + config_name: Union[str, _models.MigrationConfigurationName], **kwargs: Any ) -> _models.MigrationConfigProperties: """Retrieves Migration Config. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :type config_name: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.MigrationConfigurationName :keyword callable cls: A custom type or function that will be passed the direct response - :return: MigrationConfigProperties, or the result of cls(response) + :return: MigrationConfigProperties or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.MigrationConfigProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MigrationConfigProperties] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + cls: ClsType[_models.MigrationConfigProperties] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, config_name=config_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -652,70 +771,74 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('MigrationConfigProperties', pipeline_response) + deserialized = self._deserialize("MigrationConfigProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}" + } @distributed_trace def complete_migration( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], + config_name: Union[str, _models.MigrationConfigurationName], **kwargs: Any ) -> None: """This operation Completes Migration of entities by pointing the connection strings to Premium namespace and any entities created after the operation will be under Premium Namespace. CompleteMigration operation will fail when entity migration is in-progress. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :type config_name: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.MigrationConfigurationName :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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_complete_migration_request( resource_group_name=resource_group_name, namespace_name=namespace_name, config_name=config_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.complete_migration.metadata['url'], + template_url=self.complete_migration.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -726,61 +849,65 @@ def complete_migration( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - complete_migration.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/upgrade"} # type: ignore - + complete_migration.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/upgrade" + } @distributed_trace def revert( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], + config_name: Union[str, _models.MigrationConfigurationName], **kwargs: Any ) -> None: """This operation reverts Migration. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :type config_name: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.MigrationConfigurationName :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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_revert_request( resource_group_name=resource_group_name, namespace_name=namespace_name, config_name=config_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.revert.metadata['url'], + template_url=self.revert.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -791,5 +918,6 @@ def revert( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - revert.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/revert"} # type: ignore - + revert.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/revert" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/operations/_namespaces_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/operations/_namespaces_operations.py index a81d7686daa0c..5c4b91aad9342 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/operations/_namespaces_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/operations/_namespaces_operations.py @@ -6,11 +6,18 @@ # 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, Union, cast - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -22,651 +29,593 @@ 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') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +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, - **kwargs: Any -) -> HttpRequest: + +def build_list_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-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/namespaces") 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: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _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: + +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-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _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( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - *, - json: Optional[_models.SBNamespace] = None, - content: Any = None, - **kwargs: Any + +def build_create_or_update_request( + resource_group_name: str, namespace_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-01-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: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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, - 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( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - **kwargs: Any + +def build_delete_request( + resource_group_name: str, namespace_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-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_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-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _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, - namespace_name: str, - subscription_id: str, - *, - json: Optional[_models.SBNamespaceUpdateParameters] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_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-01-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: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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, - 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_create_or_update_network_rule_set_request( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - *, - json: Optional[_models.NetworkRuleSet] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_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-01-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: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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, - 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_get_network_rule_set_request( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_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-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_network_rule_sets_request( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_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-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_authorization_rules_request( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_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-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_authorization_rule_request( - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - subscription_id: str, - *, - json: Optional[_models.SBAuthorizationRule] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_name: str, authorization_rule_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-01-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: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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, - 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_authorization_rule_request( - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, authorization_rule_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-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_authorization_rule_request( - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, authorization_rule_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-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_keys_request( - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, authorization_rule_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-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/listKeys") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/listKeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_regenerate_keys_request( - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - subscription_id: str, - *, - json: Optional[_models.RegenerateAccessKeyParameters] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_name: str, authorization_rule_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-01-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: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/regenerateKeys") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/regenerateKeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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, - 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_check_name_availability_request( - subscription_id: str, - *, - json: Optional[_models.CheckNameAvailability] = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: + +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-01-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: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/CheckNameAvailability") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/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: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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, - 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 NamespacesOperations: """ @@ -687,55 +636,60 @@ def __init__(self, *args, **kwargs): 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.SBNamespaceListResult]: + def list(self, **kwargs: Any) -> Iterable["_models.SBNamespace"]: """Gets all the available namespaces within the subscription, irrespective of the resource groups. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBNamespaceListResult or the result of - cls(response) + :return: An iterator like instance of either SBNamespace or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBNamespaceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBNamespace] + :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', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBNamespaceListResult] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + cls: ClsType[_models.SBNamespaceListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -743,16 +697,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("SBNamespaceListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -763,65 +715,67 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/namespaces"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/namespaces"} @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable[_models.SBNamespaceListResult]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.SBNamespace"]: """Gets the available namespaces within a resource group. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. 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 SBNamespaceListResult or the result of - cls(response) + :return: An iterator like instance of either SBNamespace or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBNamespaceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBNamespace] + :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', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBNamespaceListResult] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + cls: ClsType[_models.SBNamespaceListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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'], + 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 + request.url = self._client.format_url(request.url) else: - - 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=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -829,16 +783,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("SBNamespaceListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -849,90 +801,141 @@ 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.ServiceBus/namespaces"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces" + } def _create_or_update_initial( - self, - resource_group_name: str, - namespace_name: str, - parameters: _models.SBNamespace, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, parameters: Union[_models.SBNamespace, IO], **kwargs: Any ) -> Optional[_models.SBNamespace]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.SBNamespace]] - - _json = self._serialize.body(parameters, 'SBNamespace') - - request = build_create_or_update_request_initial( + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.SBNamespace]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBNamespace") + + request = build_create_or_update_request( resource_group_name=resource_group_name, namespace_name=namespace_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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('SBNamespace', pipeline_response) + deserialized = self._deserialize("SBNamespace", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('SBNamespace', pipeline_response) + deserialized = self._deserialize("SBNamespace", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore - + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}" + } - @distributed_trace + @overload def begin_create_or_update( self, resource_group_name: str, namespace_name: str, parameters: _models.SBNamespace, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.SBNamespace]: """Creates or updates a service namespace. Once created, this namespace's resource manifest is immutable. This operation is idempotent. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: Parameters supplied to create a namespace resource. + :param parameters: Parameters supplied to create a namespace resource. Required. :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBNamespace + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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 SBNamespace or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBNamespace] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.SBNamespace]: + """Creates or updates a service namespace. Once created, this namespace's resource manifest is + immutable. This operation is idempotent. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to create a namespace resource. Required. + :type 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 :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 @@ -945,121 +948,147 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBNamespace] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, resource_group_name: str, namespace_name: str, parameters: Union[_models.SBNamespace, IO], **kwargs: Any + ) -> LROPoller[_models.SBNamespace]: + """Creates or updates a service namespace. Once created, this namespace's resource manifest is + immutable. This operation is idempotent. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to create a namespace resource. Is either a model type + or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBNamespace 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 SBNamespace or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBNamespace] + :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-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBNamespace] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SBNamespace] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._create_or_update_initial( # type: ignore + raw_result = self._create_or_update_initial( resource_group_name=resource_group_name, namespace_name=namespace_name, parameters=parameters, 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): - deserialized = self._deserialize('SBNamespace', pipeline_response) + deserialized = self._deserialize("SBNamespace", 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 + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}" + } def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, **kwargs: Any ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request_initial( + request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + 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 + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}" + } @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete(self, resource_group_name: str, namespace_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes an existing namespace. This operation also removes all associated resources under the namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_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. @@ -1071,103 +1100,98 @@ def begin_delete( # pylint: disable=inconsistent-return-statements 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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: 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 + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, namespace_name=namespace_name, api_version=api_version, - 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 = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}" + } @distributed_trace - def get( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> _models.SBNamespace: + def get(self, resource_group_name: str, namespace_name: str, **kwargs: Any) -> _models.SBNamespace: """Gets a description for the specified namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBNamespace, or the result of cls(response) + :return: SBNamespace or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBNamespace - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBNamespace] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + cls: ClsType[_models.SBNamespace] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1175,51 +1199,124 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBNamespace', pipeline_response) + deserialized = self._deserialize("SBNamespace", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}" + } + + @overload + def update( + self, + resource_group_name: str, + namespace_name: str, + parameters: _models.SBNamespaceUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> Optional[_models.SBNamespace]: + """Updates a service namespace. Once created, this namespace's resource manifest is immutable. + This operation is idempotent. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to update a namespace resource. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBNamespaceUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBNamespace or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBNamespace or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> Optional[_models.SBNamespace]: + """Updates a service namespace. Once created, this namespace's resource manifest is immutable. + This operation is idempotent. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to update a namespace resource. Required. + :type 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: SBNamespace or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBNamespace or None + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def update( self, resource_group_name: str, namespace_name: str, - parameters: _models.SBNamespaceUpdateParameters, + parameters: Union[_models.SBNamespaceUpdateParameters, IO], **kwargs: Any ) -> Optional[_models.SBNamespace]: """Updates a service namespace. Once created, this namespace's resource manifest is immutable. This operation is idempotent. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: Parameters supplied to update a namespace resource. + :param parameters: Parameters supplied to update a namespace resource. Is either a model type + or a IO type. Required. :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBNamespaceUpdateParameters + 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: SBNamespace, or the result of cls(response) + :return: SBNamespace or None or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBNamespace or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.SBNamespace]] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.SBNamespace]] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'SBNamespaceUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBNamespaceUpdateParameters") request = build_update_request( resource_group_name=resource_group_name, @@ -1228,18 +1325,18 @@ def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -1249,53 +1346,122 @@ def update( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('SBNamespace', pipeline_response) + deserialized = self._deserialize("SBNamespace", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('SBNamespace', pipeline_response) + deserialized = self._deserialize("SBNamespace", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore - + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}" + } - @distributed_trace + @overload def create_or_update_network_rule_set( self, resource_group_name: str, namespace_name: str, parameters: _models.NetworkRuleSet, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.NetworkRuleSet: """Create or update NetworkRuleSet for a Namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: The Namespace IpFilterRule. + :param parameters: The Namespace IpFilterRule. Required. :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.NetworkRuleSet + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: NetworkRuleSet, or the result of cls(response) + :return: NetworkRuleSet or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.NetworkRuleSet - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_network_rule_set( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.NetworkRuleSet: + """Create or update NetworkRuleSet for a Namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: The Namespace IpFilterRule. Required. + :type 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: NetworkRuleSet or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.NetworkRuleSet + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update_network_rule_set( + self, + resource_group_name: str, + namespace_name: str, + parameters: Union[_models.NetworkRuleSet, IO], + **kwargs: Any + ) -> _models.NetworkRuleSet: + """Create or update NetworkRuleSet for a Namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: The Namespace IpFilterRule. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.NetworkRuleSet 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: NetworkRuleSet or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.NetworkRuleSet + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.NetworkRuleSet] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.NetworkRuleSet] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'NetworkRuleSet') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "NetworkRuleSet") request = build_create_or_update_network_rule_set_request( resource_group_name=resource_group_name, @@ -1304,18 +1470,18 @@ def create_or_update_network_rule_set( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_network_rule_set.metadata['url'], + content=_content, + template_url=self.create_or_update_network_rule_set.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1323,63 +1489,64 @@ def create_or_update_network_rule_set( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('NetworkRuleSet', pipeline_response) + deserialized = self._deserialize("NetworkRuleSet", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_network_rule_set.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default"} # type: ignore - + create_or_update_network_rule_set.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default" + } @distributed_trace def get_network_rule_set( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, **kwargs: Any ) -> _models.NetworkRuleSet: """Gets NetworkRuleSet for a Namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: NetworkRuleSet, or the result of cls(response) + :return: NetworkRuleSet or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.NetworkRuleSet - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.NetworkRuleSet] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + cls: ClsType[_models.NetworkRuleSet] = kwargs.pop("cls", None) - request = build_get_network_rule_set_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_network_rule_set.metadata['url'], + template_url=self.get_network_rule_set.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1387,74 +1554,79 @@ def get_network_rule_set( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('NetworkRuleSet', pipeline_response) + deserialized = self._deserialize("NetworkRuleSet", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_network_rule_set.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default"} # type: ignore - + get_network_rule_set.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default" + } @distributed_trace def list_network_rule_sets( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> Iterable[_models.NetworkRuleSetListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> Iterable["_models.NetworkRuleSet"]: """Gets list of NetworkRuleSet for a Namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either NetworkRuleSetListResult or the result of - cls(response) + :return: An iterator like instance of either NetworkRuleSet or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.NetworkRuleSetListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.NetworkRuleSet] + :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', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.NetworkRuleSetListResult] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + cls: ClsType[_models.NetworkRuleSetListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_network_rule_sets_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_network_rule_sets.metadata['url'], + template_url=self.list_network_rule_sets.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_network_rule_sets_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -1462,16 +1634,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("NetworkRuleSetListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1482,70 +1652,74 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_network_rule_sets.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets"} # type: ignore + list_network_rule_sets.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets" + } @distributed_trace def list_authorization_rules( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> Iterable[_models.SBAuthorizationRuleListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> Iterable["_models.SBAuthorizationRule"]: """Gets the authorization rules for a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of - cls(response) + :return: An iterator like instance of either SBAuthorizationRule or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRule] + :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', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRuleListResult] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + cls: ClsType[_models.SBAuthorizationRuleListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_authorization_rules_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_authorization_rules.metadata['url'], + template_url=self.list_authorization_rules.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_authorization_rules_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -1553,16 +1727,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("SBAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1573,49 +1745,124 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_authorization_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules"} # type: ignore + list_authorization_rules.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules" + } - @distributed_trace + @overload def create_or_update_authorization_rule( self, resource_group_name: str, namespace_name: str, authorization_rule_name: str, parameters: _models.SBAuthorizationRule, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SBAuthorizationRule: """Creates or updates an authorization rule for a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: The shared access authorization rule. + :param parameters: The shared access authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBAuthorizationRule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates or updates an authorization rule for a namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Required. + :type 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: SBAuthorizationRule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: Union[_models.SBAuthorizationRule, IO], + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates or updates an authorization rule for a namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRule 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: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SBAuthorizationRule] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'SBAuthorizationRule') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBAuthorizationRule") request = build_create_or_update_authorization_rule_request( resource_group_name=resource_group_name, @@ -1625,18 +1872,18 @@ def create_or_update_authorization_rule( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_authorization_rule.metadata['url'], + content=_content, + template_url=self.create_or_update_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1644,67 +1891,67 @@ def create_or_update_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}"} # type: ignore - + create_or_update_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}" + } @distributed_trace def delete_authorization_rule( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, authorization_rule_name: str, **kwargs: Any ) -> None: """Deletes a namespace authorization rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_authorization_rule.metadata['url'], + template_url=self.delete_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1715,60 +1962,60 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}"} # type: ignore - + delete_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}" + } @distributed_trace def get_authorization_rule( - self, - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, authorization_rule_name: str, **kwargs: Any ) -> _models.SBAuthorizationRule: """Gets an authorization rule for a namespace by rule name. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + cls: ClsType[_models.SBAuthorizationRule] = kwargs.pop("cls", None) - request = build_get_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_authorization_rule.metadata['url'], + template_url=self.get_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1776,67 +2023,67 @@ def get_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}"} # type: ignore - + get_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}" + } @distributed_trace def list_keys( - self, - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, authorization_rule_name: str, **kwargs: Any ) -> _models.AccessKeys: """Gets the primary and secondary connection strings for the namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + cls: ClsType[_models.AccessKeys] = kwargs.pop("cls", None) - request = build_list_keys_request( resource_group_name=resource_group_name, namespace_name=namespace_name, authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata['url'], + 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 + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1844,54 +2091,131 @@ def list_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + deserialized = self._deserialize("AccessKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/listKeys"} # type: ignore - + list_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/listKeys" + } - @distributed_trace + @overload def regenerate_keys( self, resource_group_name: str, namespace_name: str, authorization_rule_name: str, parameters: _models.RegenerateAccessKeyParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.AccessKeys: """Regenerates the primary or secondary connection strings for the namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate the authorization rule. + :param parameters: Parameters supplied to regenerate the authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.RegenerateAccessKeyParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AccessKeys: + """Regenerates the primary or secondary connection strings for the namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Required. + :type 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: AccessKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: Union[_models.RegenerateAccessKeyParameters, IO], + **kwargs: Any + ) -> _models.AccessKeys: + """Regenerates the primary or secondary connection strings for the namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Is either a model + type or a IO type. Required. + :type parameters: + ~azure.mgmt.servicebus.v2021_01_01_preview.models.RegenerateAccessKeyParameters 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: AccessKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AccessKeys] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RegenerateAccessKeyParameters") request = build_regenerate_keys_request( resource_group_name=resource_group_name, @@ -1901,18 +2225,18 @@ def regenerate_keys( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_keys.metadata['url'], + content=_content, + template_url=self.regenerate_keys.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1920,62 +2244,110 @@ def regenerate_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + deserialized = self._deserialize("AccessKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/regenerateKeys"} # type: ignore + regenerate_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/regenerateKeys" + } + + @overload + def check_name_availability( + self, parameters: _models.CheckNameAvailability, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param parameters: Parameters to check availability of the given namespace name. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.CheckNameAvailability + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckNameAvailabilityResult or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + :param parameters: Parameters to check availability of the given namespace name. Required. + :type 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: CheckNameAvailabilityResult or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def check_name_availability( - self, - parameters: _models.CheckNameAvailability, - **kwargs: Any + self, parameters: Union[_models.CheckNameAvailability, IO], **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Check the give namespace name availability. - :param parameters: Parameters to check availability of the given namespace name. - :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.CheckNameAvailability + :param parameters: Parameters to check availability of the given namespace name. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.CheckNameAvailability 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: CheckNameAvailabilityResult, or the result of cls(response) + :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.CheckNameAvailabilityResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.CheckNameAvailabilityResult] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CheckNameAvailabilityResult] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'CheckNameAvailability') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "CheckNameAvailability") 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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1983,12 +2355,13 @@ def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) + deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/CheckNameAvailability"} # type: ignore - + check_name_availability.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/CheckNameAvailability" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/operations/_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/operations/_operations.py index 9faec6420ec1c..337adda20afdf 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/operations/_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/operations/_operations.py @@ -6,11 +6,18 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,38 +27,40 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +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: + +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-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.ServiceBus/operations") # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + class Operations: """ @@ -72,52 +81,59 @@ def __init__(self, *args, **kwargs): 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 ServiceBus 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.paging.ItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_01_01_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', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_request( - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -125,16 +141,14 @@ 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) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -145,8 +159,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.ServiceBus/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.ServiceBus/operations"} diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/operations/_patch.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/operations/_patch.py index 0ad201a8c586e..f7dd32510333d 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/operations/_patch.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/operations/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/operations/_private_endpoint_connections_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/operations/_private_endpoint_connections_operations.py index f3a9dd347ae11..9f073d565c0e3 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/operations/_private_endpoint_connections_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/operations/_private_endpoint_connections_operations.py @@ -6,11 +6,18 @@ # 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, Union, cast - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -22,134 +29,140 @@ 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') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +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, - namespace_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_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-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( - subscription_id: str, resource_group_name: str, namespace_name: str, private_endpoint_connection_name: str, - *, - json: Optional[_models.PrivateEndpointConnection] = None, - content: Any = None, + 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-01-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: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/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', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "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", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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, - 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( + +def build_delete_request( resource_group_name: str, namespace_name: str, - subscription_id: 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', "2021-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( @@ -162,33 +175,37 @@ def build_get_request( _headers = case_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-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "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", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + class PrivateEndpointConnectionsOperations: """ @@ -209,65 +226,69 @@ def __init__(self, *args, **kwargs): 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, - namespace_name: str, - **kwargs: Any - ) -> Iterable[_models.PrivateEndpointConnectionListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> Iterable["_models.PrivateEndpointConnection"]: """Gets the available PrivateEndpointConnections within a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateEndpointConnectionListResult or the result - of cls(response) + :return: An iterator like instance of either PrivateEndpointConnection or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.PrivateEndpointConnectionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_01_01_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', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnectionListResult] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -275,16 +296,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -295,71 +314,148 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections" + } - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, namespace_name: str, private_endpoint_connection_name: str, parameters: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.PrivateEndpointConnection: """Creates or updates PrivateEndpointConnections of service namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param private_endpoint_connection_name: The PrivateEndpointConnection name. + :param private_endpoint_connection_name: The PrivateEndpointConnection name. Required. :type private_endpoint_connection_name: str :param parameters: Parameters supplied to update Status of PrivateEndPoint Connection to - namespace resource. + namespace resource. Required. :type parameters: ~azure.mgmt.servicebus.v2021_01_01_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 - :return: PrivateEndpointConnection, or the result of cls(response) + :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + private_endpoint_connection_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Creates or updates PrivateEndpointConnections of service namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param private_endpoint_connection_name: The PrivateEndpointConnection name. Required. + :type private_endpoint_connection_name: str + :param parameters: Parameters supplied to update Status of PrivateEndPoint Connection to + namespace resource. Required. + :type 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: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + private_endpoint_connection_name: str, + parameters: Union[_models.PrivateEndpointConnection, IO], + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Creates or updates PrivateEndpointConnections of service namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param private_endpoint_connection_name: The PrivateEndpointConnection name. Required. + :type private_endpoint_connection_name: str + :param parameters: Parameters supplied to update Status of PrivateEndPoint Connection to + namespace resource. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_01_01_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 + :return: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'PrivateEndpointConnection') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PrivateEndpointConnection") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, namespace_name=namespace_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.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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -368,83 +464,81 @@ def create_or_update( 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 cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + return deserialized # type: ignore + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}" + } def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request_initial( + request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, - subscription_id=self._config.subscription_id, 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'], + 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 + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}" + } @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, namespace_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes an existing Private Endpoint Connection. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param private_endpoint_connection_name: The PrivateEndpointConnection name. + :param private_endpoint_connection_name: The PrivateEndpointConnection name. 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. @@ -456,108 +550,104 @@ def begin_delete( # pylint: disable=inconsistent-return-statements 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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: 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 + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, namespace_name=namespace_name, private_endpoint_connection_name=private_endpoint_connection_name, api_version=api_version, - 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 = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}" + } @distributed_trace def get( - self, - resource_group_name: str, - namespace_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> _models.PrivateEndpointConnection: """Gets a description for the specified Private Endpoint Connection. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param private_endpoint_connection_name: The PrivateEndpointConnection name. + :param private_endpoint_connection_name: The PrivateEndpointConnection name. 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.servicebus.v2021_01_01_preview.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_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'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -565,12 +655,13 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, 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.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/operations/_private_link_resources_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/operations/_private_link_resources_operations.py index 9fd9e6f03a901..dd9f3a8157a4b 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/operations/_private_link_resources_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/operations/_private_link_resources_operations.py @@ -6,11 +6,17 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Optional, TypeVar -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest @@ -19,48 +25,54 @@ 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') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +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, - namespace_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_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-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateLinkResources") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateLinkResources", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + class PrivateLinkResourcesOperations: """ @@ -81,54 +93,53 @@ def __init__(self, *args, **kwargs): 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, - namespace_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, **kwargs: Any ) -> _models.PrivateLinkResourcesListResult: """Gets lists of resources that supports Privatelinks. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateLinkResourcesListResult, or the result of cls(response) + :return: PrivateLinkResourcesListResult or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.PrivateLinkResourcesListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateLinkResourcesListResult] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + cls: ClsType[_models.PrivateLinkResourcesListResult] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -136,12 +147,13 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateLinkResourcesListResult', pipeline_response) + deserialized = self._deserialize("PrivateLinkResourcesListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateLinkResources"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateLinkResources" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/operations/_queues_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/operations/_queues_operations.py index c72a7a31149f6..1c84edb31d16e 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/operations/_queues_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/operations/_queues_operations.py @@ -6,11 +6,18 @@ # 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 msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,50 +27,54 @@ 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') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_authorization_rules_request( - resource_group_name: str, - namespace_name: str, - queue_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, queue_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-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_authorization_rule_request( @@ -72,47 +83,45 @@ def build_create_or_update_authorization_rule_request( queue_name: str, authorization_rule_name: str, subscription_id: str, - *, - json: Optional[_models.SBAuthorizationRule] = None, - content: Any = 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', "2021-01-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: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', min_length=1), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, "str", min_length=1), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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, - 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_authorization_rule_request( @@ -126,34 +135,37 @@ def build_delete_authorization_rule_request( _headers = case_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-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', min_length=1), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, "str", min_length=1), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_authorization_rule_request( @@ -167,34 +179,37 @@ def build_get_authorization_rule_request( _headers = case_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-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', min_length=1), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, "str", min_length=1), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_keys_request( @@ -208,34 +223,37 @@ def build_list_keys_request( _headers = case_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-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/ListKeys") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/ListKeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', min_length=1), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, "str", min_length=1), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_regenerate_keys_request( @@ -244,47 +262,45 @@ def build_regenerate_keys_request( queue_name: str, authorization_rule_name: str, subscription_id: str, - *, - json: Optional[_models.RegenerateAccessKeyParameters] = None, - content: Any = 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', "2021-01-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: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/regenerateKeys") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/regenerateKeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', min_length=1), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, "str", min_length=1), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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, - 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_by_namespace_request( @@ -299,161 +315,149 @@ def build_list_by_namespace_request( _headers = case_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-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if skip is not None: - _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', maximum=1000, minimum=0) + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", maximum=1000, minimum=0) if top is not None: - _params['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", maximum=1000, minimum=1) # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **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( - resource_group_name: str, - namespace_name: str, - queue_name: str, - subscription_id: str, - *, - json: Optional[_models.SBQueue] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_name: str, queue_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-01-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: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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, - 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( - resource_group_name: str, - namespace_name: str, - queue_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, queue_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-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - namespace_name: str, - queue_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, queue_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-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + class QueuesOperations: """ @@ -474,70 +478,71 @@ def __init__(self, *args, **kwargs): 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_authorization_rules( - self, - resource_group_name: str, - namespace_name: str, - queue_name: str, - **kwargs: Any - ) -> Iterable[_models.SBAuthorizationRuleListResult]: + self, resource_group_name: str, namespace_name: str, queue_name: str, **kwargs: Any + ) -> Iterable["_models.SBAuthorizationRule"]: """Gets all authorization rules for a queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of - cls(response) + :return: An iterator like instance of either SBAuthorizationRule or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRule] + :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', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRuleListResult] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + cls: ClsType[_models.SBAuthorizationRuleListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_authorization_rules_request( resource_group_name=resource_group_name, namespace_name=namespace_name, queue_name=queue_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_authorization_rules.metadata['url'], + template_url=self.list_authorization_rules.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_authorization_rules_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - queue_name=queue_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -545,16 +550,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("SBAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -565,13 +568,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_authorization_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules"} # type: ignore + list_authorization_rules.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules" + } - @distributed_trace + @overload def create_or_update_authorization_rule( self, resource_group_name: str, @@ -579,38 +582,119 @@ def create_or_update_authorization_rule( queue_name: str, authorization_rule_name: str, parameters: _models.SBAuthorizationRule, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SBAuthorizationRule: """Creates an authorization rule for a queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: The shared access authorization rule. + :param parameters: The shared access authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates an authorization rule for a queue. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Required. + :type 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: SBAuthorizationRule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: Union[_models.SBAuthorizationRule, IO], + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates an authorization rule for a queue. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRule 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: SBAuthorizationRule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SBAuthorizationRule] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'SBAuthorizationRule') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBAuthorizationRule") request = build_create_or_update_authorization_rule_request( resource_group_name=resource_group_name, @@ -621,18 +705,18 @@ def create_or_update_authorization_rule( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_authorization_rule.metadata['url'], + content=_content, + template_url=self.create_or_update_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -640,15 +724,16 @@ def create_or_update_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}"} # type: ignore - + create_or_update_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}" + } @distributed_trace def delete_authorization_rule( # pylint: disable=inconsistent-return-statements @@ -661,31 +746,35 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements ) -> None: """Deletes a queue authorization rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -693,18 +782,17 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_authorization_rule.metadata['url'], + template_url=self.delete_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -715,8 +803,9 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}"} # type: ignore - + delete_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}" + } @distributed_trace def get_authorization_rule( @@ -729,31 +818,35 @@ def get_authorization_rule( ) -> _models.SBAuthorizationRule: """Gets an authorization rule for a queue by rule name. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + cls: ClsType[_models.SBAuthorizationRule] = kwargs.pop("cls", None) - request = build_get_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -761,18 +854,17 @@ def get_authorization_rule( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_authorization_rule.metadata['url'], + template_url=self.get_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -780,15 +872,16 @@ def get_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}"} # type: ignore - + get_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}" + } @distributed_trace def list_keys( @@ -801,31 +894,35 @@ def list_keys( ) -> _models.AccessKeys: """Primary and secondary connection strings to the queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + cls: ClsType[_models.AccessKeys] = kwargs.pop("cls", None) - request = build_list_keys_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -833,18 +930,17 @@ def list_keys( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata['url'], + 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 + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -852,17 +948,18 @@ def list_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + deserialized = self._deserialize("AccessKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/ListKeys"} # type: ignore - + list_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/ListKeys" + } - @distributed_trace + @overload def regenerate_keys( self, resource_group_name: str, @@ -870,39 +967,121 @@ def regenerate_keys( queue_name: str, authorization_rule_name: str, parameters: _models.RegenerateAccessKeyParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.AccessKeys: """Regenerates the primary or secondary connection strings to the queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate the authorization rule. + :param parameters: Parameters supplied to regenerate the authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.RegenerateAccessKeyParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AccessKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AccessKeys: + """Regenerates the primary or secondary connection strings to the queue. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Required. + :type 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: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: Union[_models.RegenerateAccessKeyParameters, IO], + **kwargs: Any + ) -> _models.AccessKeys: + """Regenerates the primary or secondary connection strings to the queue. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Is either a model + type or a IO type. Required. + :type parameters: + ~azure.mgmt.servicebus.v2021_01_01_preview.models.RegenerateAccessKeyParameters 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: AccessKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AccessKeys] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RegenerateAccessKeyParameters") request = build_regenerate_keys_request( resource_group_name=resource_group_name, @@ -913,18 +1092,18 @@ def regenerate_keys( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_keys.metadata['url'], + content=_content, + template_url=self.regenerate_keys.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -932,15 +1111,16 @@ def regenerate_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + deserialized = self._deserialize("AccessKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/regenerateKeys"} # type: ignore - + regenerate_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/regenerateKeys" + } @distributed_trace def list_by_namespace( @@ -950,12 +1130,12 @@ def list_by_namespace( skip: Optional[int] = None, top: Optional[int] = None, **kwargs: Any - ) -> Iterable[_models.SBQueueListResult]: + ) -> Iterable["_models.SBQueue"]: """Gets the queues within a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :param skip: Skip is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skip @@ -965,53 +1145,58 @@ def list_by_namespace( Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBQueueListResult or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBQueueListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either SBQueue or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBQueue] + :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', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBQueueListResult] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + cls: ClsType[_models.SBQueueListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_namespace_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, - api_version=api_version, skip=skip, top=top, - template_url=self.list_by_namespace.metadata['url'], + api_version=api_version, + template_url=self.list_by_namespace.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_by_namespace_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - skip=skip, - top=top, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -1019,16 +1204,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("SBQueueListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1039,49 +1222,124 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_namespace.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues"} # type: ignore + list_by_namespace.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues" + } - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, namespace_name: str, queue_name: str, parameters: _models.SBQueue, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SBQueue: """Creates or updates a Service Bus queue. This operation is idempotent. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param parameters: Parameters supplied to create or update a queue resource. + :param parameters: Parameters supplied to create or update a queue resource. Required. :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBQueue + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBQueue or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBQueue: + """Creates or updates a Service Bus queue. This operation is idempotent. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param parameters: Parameters supplied to create or update a queue resource. Required. + :type 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: SBQueue, or the result of cls(response) + :return: SBQueue or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBQueue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + parameters: Union[_models.SBQueue, IO], + **kwargs: Any + ) -> _models.SBQueue: + """Creates or updates a Service Bus queue. This operation is idempotent. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param parameters: Parameters supplied to create or update a queue resource. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBQueue 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: SBQueue or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBQueue + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBQueue] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SBQueue] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'SBQueue') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBQueue") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -1091,18 +1349,18 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - 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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1110,67 +1368,67 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBQueue', pipeline_response) + deserialized = self._deserialize("SBQueue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}"} # type: ignore - + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}" + } @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - queue_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, queue_name: str, **kwargs: Any ) -> None: """Deletes a queue from the specified namespace in a resource group. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, queue_name=queue_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1181,60 +1439,58 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}"} # type: ignore - + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}" + } @distributed_trace - def get( - self, - resource_group_name: str, - namespace_name: str, - queue_name: str, - **kwargs: Any - ) -> _models.SBQueue: + def get(self, resource_group_name: str, namespace_name: str, queue_name: str, **kwargs: Any) -> _models.SBQueue: """Returns a description for the specified queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBQueue, or the result of cls(response) + :return: SBQueue or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBQueue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBQueue] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + cls: ClsType[_models.SBQueue] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, queue_name=queue_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1242,12 +1498,13 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBQueue', pipeline_response) + deserialized = self._deserialize("SBQueue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/operations/_rules_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/operations/_rules_operations.py index 0b08d466999a3..45ce3bbc14fd6 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/operations/_rules_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/operations/_rules_operations.py @@ -6,11 +6,18 @@ # 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 msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,13 +27,20 @@ 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') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +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_subscriptions_request( resource_group_name: str, namespace_name: str, @@ -41,38 +55,39 @@ def build_list_by_subscriptions_request( _headers = case_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-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, "str", max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if skip is not None: - _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', maximum=1000, minimum=0) + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", maximum=1000, minimum=0) if top is not None: - _params['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", maximum=1000, minimum=1) # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **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( @@ -82,48 +97,44 @@ def build_create_or_update_request( subscription_name: str, rule_name: str, subscription_id: str, - *, - json: Optional[_models.Rule] = None, - content: Any = 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', "2021-01-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: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - "ruleName": _SERIALIZER.url("rule_name", rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, "str", max_length=50, min_length=1), + "ruleName": _SERIALIZER.url("rule_name", rule_name, "str", max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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, - 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( @@ -138,35 +149,36 @@ def build_delete_request( _headers = case_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-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - "ruleName": _SERIALIZER.url("rule_name", rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, "str", max_length=50, min_length=1), + "ruleName": _SERIALIZER.url("rule_name", rule_name, "str", max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( @@ -181,35 +193,37 @@ def build_get_request( _headers = case_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-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - "ruleName": _SERIALIZER.url("rule_name", rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, "str", max_length=50, min_length=1), + "ruleName": _SERIALIZER.url("rule_name", rule_name, "str", max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + class RulesOperations: """ @@ -230,7 +244,6 @@ def __init__(self, *args, **kwargs): 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_subscriptions( self, @@ -241,16 +254,16 @@ def list_by_subscriptions( skip: Optional[int] = None, top: Optional[int] = None, **kwargs: Any - ) -> Iterable[_models.RuleListResult]: + ) -> Iterable["_models.Rule"]: """List all the rules within given topic-subscription. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str :param skip: Skip is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skip @@ -260,57 +273,60 @@ def list_by_subscriptions( Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RuleListResult or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.RuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Rule or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.Rule] + :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', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.RuleListResult] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + cls: ClsType[_models.RuleListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscriptions_request( resource_group_name=resource_group_name, namespace_name=namespace_name, topic_name=topic_name, subscription_name=subscription_name, subscription_id=self._config.subscription_id, - api_version=api_version, skip=skip, top=top, - template_url=self.list_by_subscriptions.metadata['url'], + api_version=api_version, + template_url=self.list_by_subscriptions.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_by_subscriptions_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - topic_name=topic_name, - subscription_name=subscription_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - skip=skip, - top=top, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -318,16 +334,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("RuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -338,13 +352,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_subscriptions.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules"} # type: ignore + list_by_subscriptions.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules" + } - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, @@ -353,40 +367,127 @@ def create_or_update( subscription_name: str, rule_name: str, parameters: _models.Rule, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.Rule: """Creates a new rule and updates an existing rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str - :param rule_name: The rule name. + :param rule_name: The rule name. Required. :type rule_name: str - :param parameters: Parameters supplied to create a rule. + :param parameters: Parameters supplied to create a rule. Required. :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.Rule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Rule, or the result of cls(response) + :return: Rule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.Rule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Rule: + """Creates a new rule and updates an existing rule. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param rule_name: The rule name. Required. + :type rule_name: str + :param parameters: Parameters supplied to create a rule. Required. + :type 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: Rule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.Rule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + rule_name: str, + parameters: Union[_models.Rule, IO], + **kwargs: Any + ) -> _models.Rule: + """Creates a new rule and updates an existing rule. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param rule_name: The rule name. Required. + :type rule_name: str + :param parameters: Parameters supplied to create a rule. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.Rule 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: Rule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.Rule + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.Rule] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Rule] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'Rule') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Rule") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -398,18 +499,18 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - 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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -417,15 +518,16 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Rule', pipeline_response) + deserialized = self._deserialize("Rule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}"} # type: ignore - + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}" + } @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -439,33 +541,37 @@ def delete( # pylint: disable=inconsistent-return-statements ) -> None: """Deletes an existing rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str - :param rule_name: The rule name. + :param rule_name: The rule name. Required. :type rule_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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -474,18 +580,17 @@ def delete( # pylint: disable=inconsistent-return-statements rule_name=rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -496,8 +601,9 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}"} # type: ignore - + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}" + } @distributed_trace def get( @@ -511,33 +617,37 @@ def get( ) -> _models.Rule: """Retrieves the description for the specified rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str - :param rule_name: The rule name. + :param rule_name: The rule name. Required. :type rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Rule, or the result of cls(response) + :return: Rule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.Rule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Rule] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + cls: ClsType[_models.Rule] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -546,18 +656,17 @@ def get( rule_name=rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -565,12 +674,13 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Rule', pipeline_response) + deserialized = self._deserialize("Rule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/operations/_subscriptions_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/operations/_subscriptions_operations.py index 92a358c44679c..316571791c88a 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/operations/_subscriptions_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/operations/_subscriptions_operations.py @@ -6,11 +6,18 @@ # 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 msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,13 +27,20 @@ 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') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +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_topic_request( resource_group_name: str, namespace_name: str, @@ -40,37 +54,38 @@ def build_list_by_topic_request( _headers = case_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-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if skip is not None: - _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', maximum=1000, minimum=0) + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", maximum=1000, minimum=0) if top is not None: - _params['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", maximum=1000, minimum=1) # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **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( @@ -79,47 +94,43 @@ def build_create_or_update_request( topic_name: str, subscription_name: str, subscription_id: str, - *, - json: Optional[_models.SBSubscription] = None, - content: Any = 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', "2021-01-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: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, "str", max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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, - 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( @@ -133,34 +144,35 @@ def build_delete_request( _headers = case_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-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, "str", max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( @@ -174,34 +186,36 @@ def build_get_request( _headers = case_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-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, "str", max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + class SubscriptionsOperations: """ @@ -222,7 +236,6 @@ def __init__(self, *args, **kwargs): 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_topic( self, @@ -232,14 +245,14 @@ def list_by_topic( skip: Optional[int] = None, top: Optional[int] = None, **kwargs: Any - ) -> Iterable[_models.SBSubscriptionListResult]: + ) -> Iterable["_models.SBSubscription"]: """List all the subscriptions under a specified topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str :param skip: Skip is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skip @@ -249,56 +262,60 @@ def list_by_topic( Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBSubscriptionListResult or the result of - cls(response) + :return: An iterator like instance of either SBSubscription or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBSubscriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBSubscription] + :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', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBSubscriptionListResult] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + cls: ClsType[_models.SBSubscriptionListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_topic_request( resource_group_name=resource_group_name, namespace_name=namespace_name, topic_name=topic_name, subscription_id=self._config.subscription_id, - api_version=api_version, skip=skip, top=top, - template_url=self.list_by_topic.metadata['url'], + api_version=api_version, + template_url=self.list_by_topic.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_by_topic_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - topic_name=topic_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - skip=skip, - top=top, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -306,16 +323,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("SBSubscriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -326,13 +341,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_topic.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions"} # type: ignore + list_by_topic.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions" + } - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, @@ -340,38 +355,119 @@ def create_or_update( topic_name: str, subscription_name: str, parameters: _models.SBSubscription, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SBSubscription: """Creates a topic subscription. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str - :param parameters: Parameters supplied to create a subscription resource. + :param parameters: Parameters supplied to create a subscription resource. Required. :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBSubscription + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBSubscription or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBSubscription + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBSubscription: + """Creates a topic subscription. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param parameters: Parameters supplied to create a subscription resource. Required. + :type 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: SBSubscription or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBSubscription + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + parameters: Union[_models.SBSubscription, IO], + **kwargs: Any + ) -> _models.SBSubscription: + """Creates a topic subscription. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param parameters: Parameters supplied to create a subscription resource. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBSubscription 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: SBSubscription, or the result of cls(response) + :return: SBSubscription or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBSubscription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBSubscription] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SBSubscription] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'SBSubscription') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBSubscription") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -382,18 +478,18 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - 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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -401,52 +497,52 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBSubscription', pipeline_response) + deserialized = self._deserialize("SBSubscription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}"} # type: ignore - + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}" + } @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - subscription_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, topic_name: str, subscription_name: str, **kwargs: Any ) -> None: """Deletes a subscription from the specified topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -454,18 +550,17 @@ def delete( # pylint: disable=inconsistent-return-statements subscription_name=subscription_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -476,45 +571,45 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}"} # type: ignore - + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}" + } @distributed_trace def get( - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - subscription_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, topic_name: str, subscription_name: str, **kwargs: Any ) -> _models.SBSubscription: """Returns a subscription description for the specified topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBSubscription, or the result of cls(response) + :return: SBSubscription or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBSubscription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBSubscription] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + cls: ClsType[_models.SBSubscription] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -522,18 +617,17 @@ def get( subscription_name=subscription_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -541,12 +635,13 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBSubscription', pipeline_response) + deserialized = self._deserialize("SBSubscription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/operations/_topics_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/operations/_topics_operations.py index 8791f787584f8..d7773a7a4d7f1 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/operations/_topics_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/operations/_topics_operations.py @@ -6,11 +6,18 @@ # 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 msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,50 +27,54 @@ 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') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_authorization_rules_request( - resource_group_name: str, - namespace_name: str, - topic_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, topic_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-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_authorization_rule_request( @@ -72,47 +83,45 @@ def build_create_or_update_authorization_rule_request( topic_name: str, authorization_rule_name: str, subscription_id: str, - *, - json: Optional[_models.SBAuthorizationRule] = None, - content: Any = 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', "2021-01-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: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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, - 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_get_authorization_rule_request( @@ -126,34 +135,37 @@ def build_get_authorization_rule_request( _headers = case_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-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_authorization_rule_request( @@ -167,34 +179,37 @@ def build_delete_authorization_rule_request( _headers = case_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-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_list_keys_request( @@ -208,34 +223,37 @@ def build_list_keys_request( _headers = case_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-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/ListKeys") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/ListKeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_regenerate_keys_request( @@ -244,47 +262,45 @@ def build_regenerate_keys_request( topic_name: str, authorization_rule_name: str, subscription_id: str, - *, - json: Optional[_models.RegenerateAccessKeyParameters] = None, - content: Any = 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', "2021-01-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: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/regenerateKeys") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/regenerateKeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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, - 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_by_namespace_request( @@ -299,161 +315,149 @@ def build_list_by_namespace_request( _headers = case_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-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if skip is not None: - _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', maximum=1000, minimum=0) + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", maximum=1000, minimum=0) if top is not None: - _params['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", maximum=1000, minimum=1) # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **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( - resource_group_name: str, - namespace_name: str, - topic_name: str, - subscription_id: str, - *, - json: Optional[_models.SBTopic] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_name: str, topic_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-01-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: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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, - 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( - resource_group_name: str, - namespace_name: str, - topic_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, topic_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-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - namespace_name: str, - topic_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, topic_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-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + class TopicsOperations: """ @@ -474,70 +478,71 @@ def __init__(self, *args, **kwargs): 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_authorization_rules( - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - **kwargs: Any - ) -> Iterable[_models.SBAuthorizationRuleListResult]: + self, resource_group_name: str, namespace_name: str, topic_name: str, **kwargs: Any + ) -> Iterable["_models.SBAuthorizationRule"]: """Gets authorization rules for a topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of - cls(response) + :return: An iterator like instance of either SBAuthorizationRule or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRule] + :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', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRuleListResult] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + cls: ClsType[_models.SBAuthorizationRuleListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_authorization_rules_request( resource_group_name=resource_group_name, namespace_name=namespace_name, topic_name=topic_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_authorization_rules.metadata['url'], + template_url=self.list_authorization_rules.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_authorization_rules_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - topic_name=topic_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -545,16 +550,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("SBAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -565,13 +568,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_authorization_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules"} # type: ignore + list_authorization_rules.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules" + } - @distributed_trace + @overload def create_or_update_authorization_rule( self, resource_group_name: str, @@ -579,38 +582,119 @@ def create_or_update_authorization_rule( topic_name: str, authorization_rule_name: str, parameters: _models.SBAuthorizationRule, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SBAuthorizationRule: """Creates an authorization rule for the specified topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: The shared access authorization rule. + :param parameters: The shared access authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates an authorization rule for the specified topic. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Required. + :type 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: SBAuthorizationRule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: Union[_models.SBAuthorizationRule, IO], + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates an authorization rule for the specified topic. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRule 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: SBAuthorizationRule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SBAuthorizationRule] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'SBAuthorizationRule') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBAuthorizationRule") request = build_create_or_update_authorization_rule_request( resource_group_name=resource_group_name, @@ -621,18 +705,18 @@ def create_or_update_authorization_rule( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_authorization_rule.metadata['url'], + content=_content, + template_url=self.create_or_update_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -640,15 +724,16 @@ def create_or_update_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}"} # type: ignore - + create_or_update_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}" + } @distributed_trace def get_authorization_rule( @@ -661,31 +746,35 @@ def get_authorization_rule( ) -> _models.SBAuthorizationRule: """Returns the specified authorization rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + cls: ClsType[_models.SBAuthorizationRule] = kwargs.pop("cls", None) - request = build_get_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -693,18 +782,17 @@ def get_authorization_rule( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_authorization_rule.metadata['url'], + template_url=self.get_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -712,15 +800,16 @@ def get_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}"} # type: ignore - + get_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}" + } @distributed_trace def delete_authorization_rule( # pylint: disable=inconsistent-return-statements @@ -733,31 +822,35 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements ) -> None: """Deletes a topic authorization rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -765,18 +858,17 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_authorization_rule.metadata['url'], + template_url=self.delete_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -787,8 +879,9 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}"} # type: ignore - + delete_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}" + } @distributed_trace def list_keys( @@ -801,31 +894,35 @@ def list_keys( ) -> _models.AccessKeys: """Gets the primary and secondary connection strings for the topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + cls: ClsType[_models.AccessKeys] = kwargs.pop("cls", None) - request = build_list_keys_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -833,18 +930,17 @@ def list_keys( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata['url'], + 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 + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -852,17 +948,18 @@ def list_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + deserialized = self._deserialize("AccessKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/ListKeys"} # type: ignore - + list_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/ListKeys" + } - @distributed_trace + @overload def regenerate_keys( self, resource_group_name: str, @@ -870,39 +967,121 @@ def regenerate_keys( topic_name: str, authorization_rule_name: str, parameters: _models.RegenerateAccessKeyParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.AccessKeys: """Regenerates primary or secondary connection strings for the topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate the authorization rule. + :param parameters: Parameters supplied to regenerate the authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.RegenerateAccessKeyParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AccessKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AccessKeys: + """Regenerates primary or secondary connection strings for the topic. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Required. + :type 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: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: Union[_models.RegenerateAccessKeyParameters, IO], + **kwargs: Any + ) -> _models.AccessKeys: + """Regenerates primary or secondary connection strings for the topic. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Is either a model + type or a IO type. Required. + :type parameters: + ~azure.mgmt.servicebus.v2021_01_01_preview.models.RegenerateAccessKeyParameters 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: AccessKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AccessKeys] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RegenerateAccessKeyParameters") request = build_regenerate_keys_request( resource_group_name=resource_group_name, @@ -913,18 +1092,18 @@ def regenerate_keys( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_keys.metadata['url'], + content=_content, + template_url=self.regenerate_keys.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -932,15 +1111,16 @@ def regenerate_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + deserialized = self._deserialize("AccessKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/regenerateKeys"} # type: ignore - + regenerate_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/regenerateKeys" + } @distributed_trace def list_by_namespace( @@ -950,12 +1130,12 @@ def list_by_namespace( skip: Optional[int] = None, top: Optional[int] = None, **kwargs: Any - ) -> Iterable[_models.SBTopicListResult]: + ) -> Iterable["_models.SBTopic"]: """Gets all the topics in a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :param skip: Skip is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skip @@ -965,53 +1145,58 @@ def list_by_namespace( Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBTopicListResult or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBTopicListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either SBTopic or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBTopic] + :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', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBTopicListResult] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + cls: ClsType[_models.SBTopicListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_namespace_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, - api_version=api_version, skip=skip, top=top, - template_url=self.list_by_namespace.metadata['url'], + api_version=api_version, + template_url=self.list_by_namespace.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_by_namespace_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - skip=skip, - top=top, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -1019,16 +1204,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("SBTopicListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1039,49 +1222,124 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_namespace.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics"} # type: ignore + list_by_namespace.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics" + } - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, namespace_name: str, topic_name: str, parameters: _models.SBTopic, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SBTopic: """Creates a topic in the specified namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param parameters: Parameters supplied to create a topic resource. + :param parameters: Parameters supplied to create a topic resource. Required. :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBTopic + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBTopic or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBTopic + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBTopic: + """Creates a topic in the specified namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param parameters: Parameters supplied to create a topic resource. Required. + :type 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: SBTopic, or the result of cls(response) + :return: SBTopic or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBTopic - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + parameters: Union[_models.SBTopic, IO], + **kwargs: Any + ) -> _models.SBTopic: + """Creates a topic in the specified namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param parameters: Parameters supplied to create a topic resource. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBTopic 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: SBTopic or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBTopic + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBTopic] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SBTopic] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'SBTopic') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBTopic") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -1091,18 +1349,18 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - 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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1110,67 +1368,67 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBTopic', pipeline_response) + deserialized = self._deserialize("SBTopic", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}"} # type: ignore - + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}" + } @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, topic_name: str, **kwargs: Any ) -> None: """Deletes a topic from the specified namespace and resource group. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, topic_name=topic_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1181,60 +1439,58 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}"} # type: ignore - + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}" + } @distributed_trace - def get( - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - **kwargs: Any - ) -> _models.SBTopic: + def get(self, resource_group_name: str, namespace_name: str, topic_name: str, **kwargs: Any) -> _models.SBTopic: """Returns a description for the specified topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBTopic, or the result of cls(response) + :return: SBTopic or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBTopic - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBTopic] + api_version: Literal["2021-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-01-preview") + ) + cls: ClsType[_models.SBTopic] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, topic_name=topic_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1242,12 +1498,13 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBTopic', pipeline_response) + deserialized = self._deserialize("SBTopic", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/__init__.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/__init__.py index 221541a00fb6e..2e171d69863bf 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/__init__.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/__init__.py @@ -13,11 +13,14 @@ try: from ._patch import __all__ as _patch_all - from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import + from ._patch import * # pylint: disable=unused-wildcard-import except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['ServiceBusManagementClient'] + +__all__ = [ + "ServiceBusManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/_configuration.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/_configuration.py index 91585e68502ca..a9f6a74af2358 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/_configuration.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from ._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential @@ -25,24 +31,19 @@ class ServiceBusManagementClientConfiguration(Configuration): # pylint: disable 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: Subscription credentials that uniquely identify a Microsoft Azure - subscription. The subscription ID forms part of the URI for every service call. + subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2021-06-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(ServiceBusManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + api_version: Literal["2021-06-01-preview"] = kwargs.pop("api_version", "2021-06-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -52,23 +53,21 @@ def __init__( 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-servicebus/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-servicebus/{}".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') + 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.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/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/_metadata.json b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/_metadata.json index d5209a713f9df..8ad2e21092fc6 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/_metadata.json +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_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\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ServiceBusManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"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\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ServiceBusManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"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\": [\"ServiceBusManagementClientConfiguration\"], \".._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\": [\"ServiceBusManagementClientConfiguration\"], \"..._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": "Subscription credentials that uniquely identify a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.", + "signature": "subscription_id: str,", + "description": "Subscription credentials that uniquely identify a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. 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": "Subscription credentials that uniquely identify a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.", + "description": "Subscription credentials that uniquely identify a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. Required.", "docstring_type": "str", "required": true } @@ -48,19 +48,19 @@ "service_client_specific": { "sync": { "api_version": { - "signature": "api_version=None, # type: Optional[str]", + "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=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false }, "profile": { - "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "signature": "profile: KnownProfiles=KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", "required": false @@ -108,4 +108,4 @@ "rules": "RulesOperations", "subscriptions": "SubscriptionsOperations" } -} \ No newline at end of file +} diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/_patch.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/_patch.py index 0ad201a8c586e..f7dd32510333d 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/_patch.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/_service_bus_management_client.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/_service_bus_management_client.py index e7ba0ba9ea96d..c49d5baed105d 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/_service_bus_management_client.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/_service_bus_management_client.py @@ -9,20 +9,31 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from . import models +from . import models as _models +from .._serialization import Deserializer, Serializer from ._configuration import ServiceBusManagementClientConfiguration -from .operations import DisasterRecoveryConfigsOperations, MigrationConfigsOperations, NamespacesOperations, Operations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, QueuesOperations, RulesOperations, SubscriptionsOperations, TopicsOperations +from .operations import ( + DisasterRecoveryConfigsOperations, + MigrationConfigsOperations, + NamespacesOperations, + Operations, + PrivateEndpointConnectionsOperations, + PrivateLinkResourcesOperations, + QueuesOperations, + RulesOperations, + SubscriptionsOperations, + TopicsOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class ServiceBusManagementClient: # pylint: disable=too-many-instance-attributes + +class ServiceBusManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Azure Service Bus client for managing Namespace. :ivar namespaces: NamespacesOperations operations @@ -50,10 +61,10 @@ class ServiceBusManagementClient: # pylint: disable=too-many-instance-attribu :ivar subscriptions: SubscriptionsOperations operations :vartype subscriptions: azure.mgmt.servicebus.v2021_06_01_preview.operations.SubscriptionsOperations - :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: Subscription credentials that uniquely identify a Microsoft Azure - subscription. The subscription ID forms part of the URI for every service call. + subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -71,50 +82,35 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = ServiceBusManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = ServiceBusManagementClientConfiguration( + 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)} + 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.namespaces = NamespacesOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.namespaces = NamespacesOperations(self._client, self._config, self._serialize, self._deserialize) self.private_endpoint_connections = PrivateEndpointConnectionsOperations( self._client, self._config, self._serialize, self._deserialize ) self.private_link_resources = PrivateLinkResourcesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize - ) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) self.disaster_recovery_configs = DisasterRecoveryConfigsOperations( self._client, self._config, self._serialize, self._deserialize ) self.migration_configs = MigrationConfigsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.queues = QueuesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.topics = TopicsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.rules = RulesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.subscriptions = SubscriptionsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - + self.queues = QueuesOperations(self._client, self._config, self._serialize, self._deserialize) + self.topics = TopicsOperations(self._client, self._config, self._serialize, self._deserialize) + self.rules = RulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.subscriptions = SubscriptionsOperations(self._client, self._config, self._serialize, self._deserialize) - def _send_request( - self, - request: 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 @@ -123,7 +119,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 @@ -136,15 +132,12 @@ def _send_request( request_copy.url = self._client.format_url(request_copy.url) return self._client.send_request(request_copy, **kwargs) - def close(self): - # type: () -> None + def close(self) -> None: self._client.close() - def __enter__(self): - # type: () -> ServiceBusManagementClient + def __enter__(self) -> "ServiceBusManagementClient": self._client.__enter__() return self - def __exit__(self, *exc_details): - # type: (Any) -> None + def __exit__(self, *exc_details) -> None: self._client.__exit__(*exc_details) diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/_vendor.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/_vendor.py index 138f663c53a4e..9aad73fc743e7 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/_vendor.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_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/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/_version.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/_version.py index 920456322fa12..e5754a47ce68f 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/_version.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "8.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/__init__.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/__init__.py index e7dd87df1f939..530b8638dfd32 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/__init__.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/__init__.py @@ -10,11 +10,14 @@ try: from ._patch import __all__ as _patch_all - from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import + from ._patch import * # pylint: disable=unused-wildcard-import except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['ServiceBusManagementClient'] + +__all__ = [ + "ServiceBusManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/_configuration.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/_configuration.py index 6b3e32290dc5f..40d264d090e40 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/_configuration.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from .._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential @@ -25,24 +31,19 @@ class ServiceBusManagementClientConfiguration(Configuration): # pylint: disable 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: Subscription credentials that uniquely identify a Microsoft Azure - subscription. The subscription ID forms part of the URI for every service call. + subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2021-06-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(ServiceBusManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + api_version: Literal["2021-06-01-preview"] = kwargs.pop("api_version", "2021-06-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -52,22 +53,21 @@ def __init__( 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-servicebus/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-servicebus/{}".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/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/_patch.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/_patch.py index 0ad201a8c586e..f7dd32510333d 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/_patch.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/_service_bus_management_client.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/_service_bus_management_client.py index e1e25354debf2..f4e3c70bfcb3d 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/_service_bus_management_client.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/_service_bus_management_client.py @@ -9,20 +9,31 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from .. import models +from .. import models as _models +from ..._serialization import Deserializer, Serializer from ._configuration import ServiceBusManagementClientConfiguration -from .operations import DisasterRecoveryConfigsOperations, MigrationConfigsOperations, NamespacesOperations, Operations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, QueuesOperations, RulesOperations, SubscriptionsOperations, TopicsOperations +from .operations import ( + DisasterRecoveryConfigsOperations, + MigrationConfigsOperations, + NamespacesOperations, + Operations, + PrivateEndpointConnectionsOperations, + PrivateLinkResourcesOperations, + QueuesOperations, + RulesOperations, + SubscriptionsOperations, + TopicsOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class ServiceBusManagementClient: # pylint: disable=too-many-instance-attributes + +class ServiceBusManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Azure Service Bus client for managing Namespace. :ivar namespaces: NamespacesOperations operations @@ -51,10 +62,10 @@ class ServiceBusManagementClient: # pylint: disable=too-many-instance-attribu :ivar subscriptions: SubscriptionsOperations operations :vartype subscriptions: azure.mgmt.servicebus.v2021_06_01_preview.aio.operations.SubscriptionsOperations - :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: Subscription credentials that uniquely identify a Microsoft Azure - subscription. The subscription ID forms part of the URI for every service call. + subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -72,50 +83,35 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = ServiceBusManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = ServiceBusManagementClientConfiguration( + 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)} + 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.namespaces = NamespacesOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.namespaces = NamespacesOperations(self._client, self._config, self._serialize, self._deserialize) self.private_endpoint_connections = PrivateEndpointConnectionsOperations( self._client, self._config, self._serialize, self._deserialize ) self.private_link_resources = PrivateLinkResourcesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize - ) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) self.disaster_recovery_configs = DisasterRecoveryConfigsOperations( self._client, self._config, self._serialize, self._deserialize ) self.migration_configs = MigrationConfigsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.queues = QueuesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.topics = TopicsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.rules = RulesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.subscriptions = SubscriptionsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - + self.queues = QueuesOperations(self._client, self._config, self._serialize, self._deserialize) + self.topics = TopicsOperations(self._client, self._config, self._serialize, self._deserialize) + self.rules = RulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.subscriptions = SubscriptionsOperations(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 @@ -124,7 +120,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/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/operations/__init__.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/operations/__init__.py index 5559ccd3746c6..e5431803c533c 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/operations/__init__.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/operations/__init__.py @@ -18,19 +18,20 @@ from ._subscriptions_operations import SubscriptionsOperations from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'NamespacesOperations', - 'PrivateEndpointConnectionsOperations', - 'PrivateLinkResourcesOperations', - 'Operations', - 'DisasterRecoveryConfigsOperations', - 'MigrationConfigsOperations', - 'QueuesOperations', - 'TopicsOperations', - 'RulesOperations', - 'SubscriptionsOperations', + "NamespacesOperations", + "PrivateEndpointConnectionsOperations", + "PrivateLinkResourcesOperations", + "Operations", + "DisasterRecoveryConfigsOperations", + "MigrationConfigsOperations", + "QueuesOperations", + "TopicsOperations", + "RulesOperations", + "SubscriptionsOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/operations/_disaster_recovery_configs_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/operations/_disaster_recovery_configs_operations.py index d30d714bf4263..985f2a49f8ad4 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/operations/_disaster_recovery_configs_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/operations/_disaster_recovery_configs_operations.py @@ -6,10 +6,19 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,27 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._disaster_recovery_configs_operations import build_break_pairing_request, build_check_name_availability_request, build_create_or_update_request, build_delete_request, build_fail_over_request, build_get_authorization_rule_request, build_get_request, build_list_authorization_rules_request, build_list_keys_request, build_list_request -T = TypeVar('T') +from ...operations._disaster_recovery_configs_operations import ( + build_break_pairing_request, + build_check_name_availability_request, + build_create_or_update_request, + build_delete_request, + build_fail_over_request, + build_get_authorization_rule_request, + build_get_request, + build_list_authorization_rules_request, + build_list_keys_request, + build_list_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class DisasterRecoveryConfigsOperations: """ .. warning:: @@ -43,41 +69,109 @@ def __init__(self, *args, **kwargs) -> None: 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 + @overload async def check_name_availability( self, resource_group_name: str, namespace_name: str, parameters: _models.CheckNameAvailability, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Check the give namespace name availability. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: Parameters to check availability of the given namespace name. + :param parameters: Parameters to check availability of the given namespace name. Required. :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.CheckNameAvailability + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckNameAvailabilityResult, or the result of cls(response) + :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.CheckNameAvailabilityResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters to check availability of the given namespace name. Required. + :type 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: CheckNameAvailabilityResult or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_name_availability( + self, + resource_group_name: str, + namespace_name: str, + parameters: Union[_models.CheckNameAvailability, IO], + **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters to check availability of the given namespace name. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.CheckNameAvailability 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: CheckNameAvailabilityResult or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.CheckNameAvailabilityResult] - - _json = self._serialize.body(parameters, 'CheckNameAvailability') + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CheckNameAvailabilityResult] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "CheckNameAvailability") request = build_check_name_availability_request( resource_group_name=resource_group_name, @@ -86,18 +180,18 @@ async def check_name_availability( 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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -105,74 +199,79 @@ async def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) + deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/CheckNameAvailability"} # type: ignore - + check_name_availability.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/CheckNameAvailability" + } @distributed_trace def list( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.ArmDisasterRecoveryListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ArmDisasterRecovery"]: """Gets all Alias(Disaster Recovery configurations). - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ArmDisasterRecoveryListResult or the result of - cls(response) + :return: An iterator like instance of either ArmDisasterRecovery or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.ArmDisasterRecoveryListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.ArmDisasterRecovery] + :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', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ArmDisasterRecoveryListResult] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.ArmDisasterRecoveryListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -180,16 +279,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("ArmDisasterRecoveryListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -200,49 +297,126 @@ 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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs" + } - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, namespace_name: str, alias: str, parameters: _models.ArmDisasterRecovery, + *, + content_type: str = "application/json", **kwargs: Any ) -> Optional[_models.ArmDisasterRecovery]: """Creates or updates a new Alias(Disaster Recovery configuration). - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: str :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). + Required. :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.ArmDisasterRecovery + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ArmDisasterRecovery, or the result of cls(response) + :return: ArmDisasterRecovery or None or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.ArmDisasterRecovery or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + alias: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> Optional[_models.ArmDisasterRecovery]: + """Creates or updates a new Alias(Disaster Recovery configuration). + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: str + :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). + Required. + :type 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: ArmDisasterRecovery or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.ArmDisasterRecovery or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + alias: str, + parameters: Union[_models.ArmDisasterRecovery, IO], + **kwargs: Any + ) -> Optional[_models.ArmDisasterRecovery]: + """Creates or updates a new Alias(Disaster Recovery configuration). + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: str + :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). Is + either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.ArmDisasterRecovery 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: ArmDisasterRecovery or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.ArmDisasterRecovery or None + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ArmDisasterRecovery]] - - _json = self._serialize.body(parameters, 'ArmDisasterRecovery') + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.ArmDisasterRecovery]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ArmDisasterRecovery") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -252,18 +426,18 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - 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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -273,67 +447,67 @@ async def create_or_update( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ArmDisasterRecovery', pipeline_response) + deserialized = self._deserialize("ArmDisasterRecovery", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}"} # type: ignore - + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}" + } @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - alias: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, alias: str, **kwargs: Any ) -> None: """Deletes an Alias(Disaster Recovery configuration). - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: 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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, alias=alias, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -344,60 +518,60 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}"} # type: ignore - + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}" + } @distributed_trace_async async def get( - self, - resource_group_name: str, - namespace_name: str, - alias: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, alias: str, **kwargs: Any ) -> _models.ArmDisasterRecovery: """Retrieves Alias(Disaster Recovery configuration) for primary or secondary namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ArmDisasterRecovery, or the result of cls(response) + :return: ArmDisasterRecovery or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.ArmDisasterRecovery - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ArmDisasterRecovery] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.ArmDisasterRecovery] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, alias=alias, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -405,68 +579,68 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ArmDisasterRecovery', pipeline_response) + deserialized = self._deserialize("ArmDisasterRecovery", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}" + } @distributed_trace_async async def break_pairing( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - alias: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, alias: str, **kwargs: Any ) -> None: """This operation disables the Disaster Recovery and stops replicating changes from primary to secondary namespaces. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: 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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_break_pairing_request( resource_group_name=resource_group_name, namespace_name=namespace_name, alias=alias, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.break_pairing.metadata['url'], + template_url=self.break_pairing.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -477,50 +651,127 @@ async def break_pairing( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - break_pairing.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/breakPairing"} # type: ignore - + break_pairing.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/breakPairing" + } - @distributed_trace_async + @overload async def fail_over( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, alias: str, parameters: Optional[_models.FailoverProperties] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> None: """Invokes GEO DR failover and reconfigure the alias to point to the secondary namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: str :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). Default value is None. :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.FailoverProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default 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: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def fail_over( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + namespace_name: str, + alias: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Invokes GEO DR failover and reconfigure the alias to point to the secondary namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: str + :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). + Default value is None. + :type 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: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def fail_over( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + namespace_name: str, + alias: str, + parameters: Optional[Union[_models.FailoverProperties, IO]] = None, + **kwargs: Any + ) -> None: + """Invokes GEO DR failover and reconfigure the alias to point to the secondary namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: str + :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). Is + either a model type or a IO type. Default value is None. + :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.FailoverProperties 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: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[None] - - if parameters is not None: - _json = self._serialize.body(parameters, 'FailoverProperties') + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "FailoverProperties") + else: + _json = None request = build_fail_over_request( resource_group_name=resource_group_name, @@ -530,18 +781,18 @@ async def fail_over( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, json=_json, - template_url=self.fail_over.metadata['url'], + content=_content, + template_url=self.fail_over.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -552,72 +803,75 @@ async def fail_over( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - fail_over.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/failover"} # type: ignore - + fail_over.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/failover" + } @distributed_trace def list_authorization_rules( - self, - resource_group_name: str, - namespace_name: str, - alias: str, - **kwargs: Any - ) -> AsyncIterable[_models.SBAuthorizationRuleListResult]: + self, resource_group_name: str, namespace_name: str, alias: str, **kwargs: Any + ) -> AsyncIterable["_models.SBAuthorizationRule"]: """Gets the authorization rules for a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of - cls(response) + :return: An iterator like instance of either SBAuthorizationRule or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRule] + :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', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRuleListResult] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.SBAuthorizationRuleListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_authorization_rules_request( resource_group_name=resource_group_name, namespace_name=namespace_name, alias=alias, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_authorization_rules.metadata['url'], + template_url=self.list_authorization_rules.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_authorization_rules_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - alias=alias, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -625,16 +879,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("SBAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -645,48 +897,47 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_authorization_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules"} # type: ignore + list_authorization_rules.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules" + } @distributed_trace_async async def get_authorization_rule( - self, - resource_group_name: str, - namespace_name: str, - alias: str, - authorization_rule_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, alias: str, authorization_rule_name: str, **kwargs: Any ) -> _models.SBAuthorizationRule: """Gets an authorization rule for a namespace by rule name. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.SBAuthorizationRule] = kwargs.pop("cls", None) - request = build_get_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -694,18 +945,17 @@ async def get_authorization_rule( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_authorization_rule.metadata['url'], + template_url=self.get_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -713,52 +963,52 @@ async def get_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules/{authorizationRuleName}"} # type: ignore - + get_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules/{authorizationRuleName}" + } @distributed_trace_async async def list_keys( - self, - resource_group_name: str, - namespace_name: str, - alias: str, - authorization_rule_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, alias: str, authorization_rule_name: str, **kwargs: Any ) -> _models.AccessKeys: """Gets the primary and secondary connection strings for the namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.AccessKeys] = kwargs.pop("cls", None) - request = build_list_keys_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -766,18 +1016,17 @@ async def list_keys( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata['url'], + 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 + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -785,12 +1034,13 @@ async def list_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + deserialized = self._deserialize("AccessKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules/{authorizationRuleName}/listKeys"} # type: ignore - + list_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules/{authorizationRuleName}/listKeys" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/operations/_migration_configs_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/operations/_migration_configs_operations.py index 5c0cde0e9ca22..3549543cde591 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/operations/_migration_configs_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/operations/_migration_configs_operations.py @@ -6,10 +6,19 @@ # 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, Union, cast +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod @@ -22,10 +31,23 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._migration_configs_operations import build_complete_migration_request, build_create_and_start_migration_request_initial, build_delete_request, build_get_request, build_list_request, build_revert_request -T = TypeVar('T') +from ...operations._migration_configs_operations import ( + build_complete_migration_request, + build_create_and_start_migration_request, + build_delete_request, + build_get_request, + build_list_request, + build_revert_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class MigrationConfigsOperations: """ .. warning:: @@ -45,65 +67,69 @@ def __init__(self, *args, **kwargs) -> None: 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, - namespace_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.MigrationConfigListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> AsyncIterable["_models.MigrationConfigProperties"]: """Gets all migrationConfigurations. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MigrationConfigListResult or the result of + :return: An iterator like instance of either MigrationConfigProperties or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.MigrationConfigListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.MigrationConfigProperties] + :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', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MigrationConfigListResult] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.MigrationConfigListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -111,16 +137,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("MigrationConfigListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -131,35 +155,46 @@ 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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations" + } async def _create_and_start_migration_initial( self, resource_group_name: str, namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], - parameters: _models.MigrationConfigProperties, + config_name: Union[str, _models.MigrationConfigurationName], + parameters: Union[_models.MigrationConfigProperties, IO], **kwargs: Any ) -> Optional[_models.MigrationConfigProperties]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.MigrationConfigProperties]] - - _json = self._serialize.body(parameters, 'MigrationConfigProperties') - - request = build_create_and_start_migration_request_initial( + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.MigrationConfigProperties]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "MigrationConfigProperties") + + request = build_create_and_start_migration_request( resource_group_name=resource_group_name, namespace_name=namespace_name, config_name=config_name, @@ -167,57 +202,146 @@ async def _create_and_start_migration_initial( api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_and_start_migration_initial.metadata['url'], + content=_content, + template_url=self._create_and_start_migration_initial.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('MigrationConfigProperties', pipeline_response) + deserialized = self._deserialize("MigrationConfigProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_and_start_migration_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}"} # type: ignore + _create_and_start_migration_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}" + } + + @overload + async def begin_create_and_start_migration( + self, + resource_group_name: str, + namespace_name: str, + config_name: Union[str, _models.MigrationConfigurationName], + parameters: _models.MigrationConfigProperties, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.MigrationConfigProperties]: + """Creates Migration configuration and starts migration of entities from Standard to Premium + namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param config_name: The configuration name. Should always be "$default". "$default" Required. + :type config_name: str or + ~azure.mgmt.servicebus.v2021_06_01_preview.models.MigrationConfigurationName + :param parameters: Parameters required to create Migration Configuration. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.MigrationConfigProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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 MigrationConfigProperties or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.servicebus.v2021_06_01_preview.models.MigrationConfigProperties] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_and_start_migration( + self, + resource_group_name: str, + namespace_name: str, + config_name: Union[str, _models.MigrationConfigurationName], + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.MigrationConfigProperties]: + """Creates Migration configuration and starts migration of entities from Standard to Premium + namespace. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param config_name: The configuration name. Should always be "$default". "$default" Required. + :type config_name: str or + ~azure.mgmt.servicebus.v2021_06_01_preview.models.MigrationConfigurationName + :param parameters: Parameters required to create Migration Configuration. Required. + :type 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 + :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 MigrationConfigProperties or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.servicebus.v2021_06_01_preview.models.MigrationConfigProperties] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_and_start_migration( self, resource_group_name: str, namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], - parameters: _models.MigrationConfigProperties, + config_name: Union[str, _models.MigrationConfigurationName], + parameters: Union[_models.MigrationConfigProperties, IO], **kwargs: Any ) -> AsyncLROPoller[_models.MigrationConfigProperties]: """Creates Migration configuration and starts migration of entities from Standard to Premium namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :type config_name: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.MigrationConfigurationName - :param parameters: Parameters required to create Migration Configuration. + :param parameters: Parameters required to create Migration Configuration. Is either a model + type or a IO type. Required. :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.MigrationConfigProperties + 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 @@ -230,114 +354,114 @@ async def begin_create_and_start_migration( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.servicebus.v2021_06_01_preview.models.MigrationConfigProperties] - :raises: ~azure.core.exceptions.HttpResponseError + :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-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.MigrationConfigProperties] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.MigrationConfigProperties] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._create_and_start_migration_initial( # type: ignore + raw_result = await self._create_and_start_migration_initial( resource_group_name=resource_group_name, namespace_name=namespace_name, config_name=config_name, parameters=parameters, 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): - deserialized = self._deserialize('MigrationConfigProperties', pipeline_response) + deserialized = self._deserialize("MigrationConfigProperties", 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 + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create_and_start_migration.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}"} # type: ignore + begin_create_and_start_migration.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}" + } @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], + config_name: Union[str, _models.MigrationConfigurationName], **kwargs: Any ) -> None: """Deletes a MigrationConfiguration. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :type config_name: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.MigrationConfigurationName :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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, config_name=config_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -348,61 +472,65 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}"} # type: ignore - + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}" + } @distributed_trace_async async def get( self, resource_group_name: str, namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], + config_name: Union[str, _models.MigrationConfigurationName], **kwargs: Any ) -> _models.MigrationConfigProperties: """Retrieves Migration Config. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :type config_name: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.MigrationConfigurationName :keyword callable cls: A custom type or function that will be passed the direct response - :return: MigrationConfigProperties, or the result of cls(response) + :return: MigrationConfigProperties or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.MigrationConfigProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MigrationConfigProperties] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.MigrationConfigProperties] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, config_name=config_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -410,70 +538,74 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('MigrationConfigProperties', pipeline_response) + deserialized = self._deserialize("MigrationConfigProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}" + } @distributed_trace_async async def complete_migration( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], + config_name: Union[str, _models.MigrationConfigurationName], **kwargs: Any ) -> None: """This operation Completes Migration of entities by pointing the connection strings to Premium namespace and any entities created after the operation will be under Premium Namespace. CompleteMigration operation will fail when entity migration is in-progress. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :type config_name: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.MigrationConfigurationName :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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_complete_migration_request( resource_group_name=resource_group_name, namespace_name=namespace_name, config_name=config_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.complete_migration.metadata['url'], + template_url=self.complete_migration.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -484,61 +616,65 @@ async def complete_migration( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - complete_migration.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/upgrade"} # type: ignore - + complete_migration.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/upgrade" + } @distributed_trace_async async def revert( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], + config_name: Union[str, _models.MigrationConfigurationName], **kwargs: Any ) -> None: """This operation reverts Migration. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :type config_name: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.MigrationConfigurationName :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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_revert_request( resource_group_name=resource_group_name, namespace_name=namespace_name, config_name=config_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.revert.metadata['url'], + template_url=self.revert.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -549,5 +685,6 @@ async def revert( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - revert.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/revert"} # type: ignore - + revert.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/revert" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/operations/_namespaces_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/operations/_namespaces_operations.py index dcf31ed61effc..0ca9bb1b9e50b 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/operations/_namespaces_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/operations/_namespaces_operations.py @@ -6,10 +6,19 @@ # 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, Union, cast +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod @@ -22,10 +31,33 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._namespaces_operations import build_check_name_availability_request, build_create_or_update_authorization_rule_request, build_create_or_update_network_rule_set_request, build_create_or_update_request_initial, build_delete_authorization_rule_request, build_delete_request_initial, build_get_authorization_rule_request, build_get_network_rule_set_request, build_get_request, build_list_authorization_rules_request, build_list_by_resource_group_request, build_list_keys_request, build_list_network_rule_sets_request, build_list_request, build_regenerate_keys_request, build_update_request -T = TypeVar('T') +from ...operations._namespaces_operations import ( + build_check_name_availability_request, + build_create_or_update_authorization_rule_request, + build_create_or_update_network_rule_set_request, + build_create_or_update_request, + build_delete_authorization_rule_request, + build_delete_request, + build_get_authorization_rule_request, + build_get_network_rule_set_request, + build_get_request, + build_list_authorization_rules_request, + build_list_by_resource_group_request, + build_list_keys_request, + build_list_network_rule_sets_request, + build_list_request, + build_regenerate_keys_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class NamespacesOperations: """ .. warning:: @@ -45,55 +77,60 @@ def __init__(self, *args, **kwargs) -> None: 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.SBNamespaceListResult]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.SBNamespace"]: """Gets all the available namespaces within the subscription, irrespective of the resource groups. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBNamespaceListResult or the result of - cls(response) + :return: An iterator like instance of either SBNamespace or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBNamespaceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBNamespace] + :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', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBNamespaceListResult] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.SBNamespaceListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -101,16 +138,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("SBNamespaceListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -121,65 +156,67 @@ 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': "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/namespaces"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/namespaces"} @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.SBNamespaceListResult]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.SBNamespace"]: """Gets the available namespaces within a resource group. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. 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 SBNamespaceListResult or the result of - cls(response) + :return: An iterator like instance of either SBNamespace or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBNamespaceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBNamespace] + :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', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBNamespaceListResult] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.SBNamespaceListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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'], + 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 + request.url = self._client.format_url(request.url) else: - - 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=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -187,16 +224,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("SBNamespaceListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -207,90 +242,173 @@ 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.ServiceBus/namespaces"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces" + } async def _create_or_update_initial( - self, - resource_group_name: str, - namespace_name: str, - parameters: _models.SBNamespace, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, parameters: Union[_models.SBNamespace, IO], **kwargs: Any ) -> Optional[_models.SBNamespace]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.SBNamespace]] - - _json = self._serialize.body(parameters, 'SBNamespace') - - request = build_create_or_update_request_initial( + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.SBNamespace]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBNamespace") + + request = build_create_or_update_request( resource_group_name=resource_group_name, namespace_name=namespace_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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('SBNamespace', pipeline_response) + deserialized = self._deserialize("SBNamespace", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('SBNamespace', pipeline_response) + deserialized = self._deserialize("SBNamespace", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore - + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}" + } - @distributed_trace_async + @overload async def begin_create_or_update( self, resource_group_name: str, namespace_name: str, parameters: _models.SBNamespace, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.SBNamespace]: """Creates or updates a service namespace. Once created, this namespace's resource manifest is immutable. This operation is idempotent. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: Parameters supplied to create a namespace resource. + :param parameters: Parameters supplied to create a namespace resource. Required. :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBNamespace + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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 SBNamespace or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBNamespace] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.SBNamespace]: + """Creates or updates a service namespace. Once created, this namespace's resource manifest is + immutable. This operation is idempotent. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to create a namespace resource. Required. + :type 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 + :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 SBNamespace or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBNamespace] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, resource_group_name: str, namespace_name: str, parameters: Union[_models.SBNamespace, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.SBNamespace]: + """Creates or updates a service namespace. Once created, this namespace's resource manifest is + immutable. This operation is idempotent. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to create a namespace resource. Is either a model type + or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBNamespace 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 @@ -303,121 +421,115 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBNamespace] - :raises: ~azure.core.exceptions.HttpResponseError + :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-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBNamespace] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SBNamespace] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._create_or_update_initial( # type: ignore + raw_result = await self._create_or_update_initial( resource_group_name=resource_group_name, namespace_name=namespace_name, parameters=parameters, 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): - deserialized = self._deserialize('SBNamespace', pipeline_response) + deserialized = self._deserialize("SBNamespace", 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 + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, **kwargs: Any ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request_initial( + request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + 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 + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}" + } @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete(self, resource_group_name: str, namespace_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes an existing namespace. This operation also removes all associated resources under the namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_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. @@ -429,103 +541,98 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements 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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: 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 + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, namespace_name=namespace_name, api_version=api_version, - 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 = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}" + } @distributed_trace_async - async def get( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> _models.SBNamespace: + async def get(self, resource_group_name: str, namespace_name: str, **kwargs: Any) -> _models.SBNamespace: """Gets a description for the specified namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBNamespace, or the result of cls(response) + :return: SBNamespace or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBNamespace - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBNamespace] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.SBNamespace] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -533,51 +640,124 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBNamespace', pipeline_response) + deserialized = self._deserialize("SBNamespace", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}" + } + @overload + async def update( + self, + resource_group_name: str, + namespace_name: str, + parameters: _models.SBNamespaceUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> Optional[_models.SBNamespace]: + """Updates a service namespace. Once created, this namespace's resource manifest is immutable. + This operation is idempotent. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to update a namespace resource. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBNamespaceUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBNamespace or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBNamespace or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> Optional[_models.SBNamespace]: + """Updates a service namespace. Once created, this namespace's resource manifest is immutable. + This operation is idempotent. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to update a namespace resource. Required. + :type 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: SBNamespace or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBNamespace or None + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def update( self, resource_group_name: str, namespace_name: str, - parameters: _models.SBNamespaceUpdateParameters, + parameters: Union[_models.SBNamespaceUpdateParameters, IO], **kwargs: Any ) -> Optional[_models.SBNamespace]: """Updates a service namespace. Once created, this namespace's resource manifest is immutable. This operation is idempotent. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: Parameters supplied to update a namespace resource. + :param parameters: Parameters supplied to update a namespace resource. Is either a model type + or a IO type. Required. :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBNamespaceUpdateParameters + 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: SBNamespace, or the result of cls(response) + :return: SBNamespace or None or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBNamespace or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.SBNamespace]] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.SBNamespace]] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'SBNamespaceUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBNamespaceUpdateParameters") request = build_update_request( resource_group_name=resource_group_name, @@ -586,18 +766,18 @@ async def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -607,53 +787,122 @@ async def update( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('SBNamespace', pipeline_response) + deserialized = self._deserialize("SBNamespace", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('SBNamespace', pipeline_response) + deserialized = self._deserialize("SBNamespace", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore - + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}" + } - @distributed_trace_async + @overload async def create_or_update_network_rule_set( self, resource_group_name: str, namespace_name: str, parameters: _models.NetworkRuleSet, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.NetworkRuleSet: """Create or update NetworkRuleSet for a Namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: The Namespace IpFilterRule. + :param parameters: The Namespace IpFilterRule. Required. :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.NetworkRuleSet + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: NetworkRuleSet, or the result of cls(response) + :return: NetworkRuleSet or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.NetworkRuleSet - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_network_rule_set( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.NetworkRuleSet: + """Create or update NetworkRuleSet for a Namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: The Namespace IpFilterRule. Required. + :type 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: NetworkRuleSet or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.NetworkRuleSet + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update_network_rule_set( + self, + resource_group_name: str, + namespace_name: str, + parameters: Union[_models.NetworkRuleSet, IO], + **kwargs: Any + ) -> _models.NetworkRuleSet: + """Create or update NetworkRuleSet for a Namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: The Namespace IpFilterRule. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.NetworkRuleSet 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: NetworkRuleSet or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.NetworkRuleSet + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.NetworkRuleSet] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.NetworkRuleSet] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'NetworkRuleSet') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "NetworkRuleSet") request = build_create_or_update_network_rule_set_request( resource_group_name=resource_group_name, @@ -662,18 +911,18 @@ async def create_or_update_network_rule_set( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_network_rule_set.metadata['url'], + content=_content, + template_url=self.create_or_update_network_rule_set.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -681,63 +930,64 @@ async def create_or_update_network_rule_set( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('NetworkRuleSet', pipeline_response) + deserialized = self._deserialize("NetworkRuleSet", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_network_rule_set.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default"} # type: ignore - + create_or_update_network_rule_set.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default" + } @distributed_trace_async async def get_network_rule_set( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, **kwargs: Any ) -> _models.NetworkRuleSet: """Gets NetworkRuleSet for a Namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: NetworkRuleSet, or the result of cls(response) + :return: NetworkRuleSet or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.NetworkRuleSet - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.NetworkRuleSet] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.NetworkRuleSet] = kwargs.pop("cls", None) - request = build_get_network_rule_set_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_network_rule_set.metadata['url'], + template_url=self.get_network_rule_set.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -745,74 +995,79 @@ async def get_network_rule_set( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('NetworkRuleSet', pipeline_response) + deserialized = self._deserialize("NetworkRuleSet", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_network_rule_set.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default"} # type: ignore - + get_network_rule_set.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default" + } @distributed_trace def list_network_rule_sets( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.NetworkRuleSetListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> AsyncIterable["_models.NetworkRuleSet"]: """Gets list of NetworkRuleSet for a Namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either NetworkRuleSetListResult or the result of - cls(response) + :return: An iterator like instance of either NetworkRuleSet or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.NetworkRuleSetListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.NetworkRuleSet] + :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', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.NetworkRuleSetListResult] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.NetworkRuleSetListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_network_rule_sets_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_network_rule_sets.metadata['url'], + template_url=self.list_network_rule_sets.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_network_rule_sets_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -820,16 +1075,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("NetworkRuleSetListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -840,70 +1093,74 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_network_rule_sets.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets"} # type: ignore + list_network_rule_sets.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets" + } @distributed_trace def list_authorization_rules( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.SBAuthorizationRuleListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> AsyncIterable["_models.SBAuthorizationRule"]: """Gets the authorization rules for a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of - cls(response) + :return: An iterator like instance of either SBAuthorizationRule or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRule] + :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', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRuleListResult] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.SBAuthorizationRuleListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_authorization_rules_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_authorization_rules.metadata['url'], + template_url=self.list_authorization_rules.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_authorization_rules_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -911,16 +1168,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("SBAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -931,49 +1186,124 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_authorization_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules"} # type: ignore + list_authorization_rules.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules" + } - @distributed_trace_async + @overload async def create_or_update_authorization_rule( self, resource_group_name: str, namespace_name: str, authorization_rule_name: str, parameters: _models.SBAuthorizationRule, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SBAuthorizationRule: """Creates or updates an authorization rule for a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: The shared access authorization rule. + :param parameters: The shared access authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBAuthorizationRule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates or updates an authorization rule for a namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Required. + :type 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: SBAuthorizationRule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: Union[_models.SBAuthorizationRule, IO], + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates or updates an authorization rule for a namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRule 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: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SBAuthorizationRule] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'SBAuthorizationRule') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBAuthorizationRule") request = build_create_or_update_authorization_rule_request( resource_group_name=resource_group_name, @@ -983,18 +1313,18 @@ async def create_or_update_authorization_rule( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_authorization_rule.metadata['url'], + content=_content, + template_url=self.create_or_update_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1002,67 +1332,67 @@ async def create_or_update_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}"} # type: ignore - + create_or_update_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}" + } @distributed_trace_async async def delete_authorization_rule( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, authorization_rule_name: str, **kwargs: Any ) -> None: """Deletes a namespace authorization rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_authorization_rule.metadata['url'], + template_url=self.delete_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1073,60 +1403,60 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat if cls: return cls(pipeline_response, None, {}) - delete_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}"} # type: ignore - + delete_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}" + } @distributed_trace_async async def get_authorization_rule( - self, - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, authorization_rule_name: str, **kwargs: Any ) -> _models.SBAuthorizationRule: """Gets an authorization rule for a namespace by rule name. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.SBAuthorizationRule] = kwargs.pop("cls", None) - request = build_get_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_authorization_rule.metadata['url'], + template_url=self.get_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1134,67 +1464,67 @@ async def get_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}"} # type: ignore - + get_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}" + } @distributed_trace_async async def list_keys( - self, - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, authorization_rule_name: str, **kwargs: Any ) -> _models.AccessKeys: """Gets the primary and secondary connection strings for the namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.AccessKeys] = kwargs.pop("cls", None) - request = build_list_keys_request( resource_group_name=resource_group_name, namespace_name=namespace_name, authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata['url'], + 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 + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1202,54 +1532,131 @@ async def list_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + deserialized = self._deserialize("AccessKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/listKeys"} # type: ignore - + list_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/listKeys" + } - @distributed_trace_async + @overload async def regenerate_keys( self, resource_group_name: str, namespace_name: str, authorization_rule_name: str, parameters: _models.RegenerateAccessKeyParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.AccessKeys: """Regenerates the primary or secondary connection strings for the namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate the authorization rule. + :param parameters: Parameters supplied to regenerate the authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.RegenerateAccessKeyParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AccessKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AccessKeys: + """Regenerates the primary or secondary connection strings for the namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Required. + :type 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: AccessKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: Union[_models.RegenerateAccessKeyParameters, IO], + **kwargs: Any + ) -> _models.AccessKeys: + """Regenerates the primary or secondary connection strings for the namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Is either a model + type or a IO type. Required. + :type parameters: + ~azure.mgmt.servicebus.v2021_06_01_preview.models.RegenerateAccessKeyParameters 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: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AccessKeys] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RegenerateAccessKeyParameters") request = build_regenerate_keys_request( resource_group_name=resource_group_name, @@ -1259,18 +1666,18 @@ async def regenerate_keys( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_keys.metadata['url'], + content=_content, + template_url=self.regenerate_keys.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1278,62 +1685,110 @@ async def regenerate_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + deserialized = self._deserialize("AccessKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/regenerateKeys"} # type: ignore + regenerate_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/regenerateKeys" + } + @overload + async def check_name_availability( + self, parameters: _models.CheckNameAvailability, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param parameters: Parameters to check availability of the given namespace name. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.CheckNameAvailability + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckNameAvailabilityResult or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param parameters: Parameters to check availability of the given namespace name. Required. + :type 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: CheckNameAvailabilityResult or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def check_name_availability( - self, - parameters: _models.CheckNameAvailability, - **kwargs: Any + self, parameters: Union[_models.CheckNameAvailability, IO], **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Check the give namespace name availability. - :param parameters: Parameters to check availability of the given namespace name. - :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.CheckNameAvailability + :param parameters: Parameters to check availability of the given namespace name. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.CheckNameAvailability 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: CheckNameAvailabilityResult, or the result of cls(response) + :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.CheckNameAvailabilityResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.CheckNameAvailabilityResult] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CheckNameAvailabilityResult] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'CheckNameAvailability') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "CheckNameAvailability") 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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1341,12 +1796,13 @@ async def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) + deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/CheckNameAvailability"} # type: ignore - + check_name_availability.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/CheckNameAvailability" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/operations/_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/operations/_operations.py index abe0a4cf460ce..6f4a7a7fb286e 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/operations/_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/operations/_operations.py @@ -6,10 +6,19 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +29,15 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._operations import build_list_request -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class Operations: """ .. warning:: @@ -42,52 +57,59 @@ def __init__(self, *args, **kwargs) -> None: 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 ServiceBus 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.servicebus.v2021_06_01_preview.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_06_01_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', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_request( - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -95,16 +117,14 @@ 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) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -115,8 +135,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.ServiceBus/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.ServiceBus/operations"} diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/operations/_patch.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/operations/_patch.py index 0ad201a8c586e..f7dd32510333d 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/operations/_patch.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/operations/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/operations/_private_endpoint_connections_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/operations/_private_endpoint_connections_operations.py index c021806113297..5fb1dc5d4102c 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/operations/_private_endpoint_connections_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/operations/_private_endpoint_connections_operations.py @@ -6,10 +6,19 @@ # 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, Union, cast +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod @@ -22,10 +31,21 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._private_endpoint_connections_operations import build_create_or_update_request, build_delete_request_initial, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._private_endpoint_connections_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class PrivateEndpointConnectionsOperations: """ .. warning:: @@ -45,65 +65,69 @@ def __init__(self, *args, **kwargs) -> None: 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, - namespace_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.PrivateEndpointConnectionListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> AsyncIterable["_models.PrivateEndpointConnection"]: """Gets the available PrivateEndpointConnections within a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateEndpointConnectionListResult or the result - of cls(response) + :return: An iterator like instance of either PrivateEndpointConnection or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.PrivateEndpointConnectionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_06_01_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', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnectionListResult] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -111,16 +135,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -131,71 +153,148 @@ 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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections" + } - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, namespace_name: str, private_endpoint_connection_name: str, parameters: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Creates or updates PrivateEndpointConnections of service namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param private_endpoint_connection_name: The PrivateEndpointConnection name. Required. + :type private_endpoint_connection_name: str + :param parameters: Parameters supplied to update Status of PrivateEndPoint Connection to + namespace resource. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_06_01_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 + :return: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + private_endpoint_connection_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Creates or updates PrivateEndpointConnections of service namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param private_endpoint_connection_name: The PrivateEndpointConnection name. Required. + :type private_endpoint_connection_name: str + :param parameters: Parameters supplied to update Status of PrivateEndPoint Connection to + namespace resource. Required. + :type 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: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + private_endpoint_connection_name: str, + parameters: Union[_models.PrivateEndpointConnection, IO], **kwargs: Any ) -> _models.PrivateEndpointConnection: """Creates or updates PrivateEndpointConnections of service namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param private_endpoint_connection_name: The PrivateEndpointConnection name. + :param private_endpoint_connection_name: The PrivateEndpointConnection name. Required. :type private_endpoint_connection_name: str :param parameters: Parameters supplied to update Status of PrivateEndPoint Connection to - namespace resource. + namespace resource. Is either a model type or a IO type. Required. :type parameters: ~azure.mgmt.servicebus.v2021_06_01_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 - :return: PrivateEndpointConnection, or the result of cls(response) + :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'PrivateEndpointConnection') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PrivateEndpointConnection") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, namespace_name=namespace_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.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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -204,83 +303,81 @@ async def create_or_update( 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 + return cls(pipeline_response, deserialized, {}) # type: ignore - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + return deserialized # type: ignore + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request_initial( + request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, - subscription_id=self._config.subscription_id, 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'], + 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 + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}" + } @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, namespace_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes an existing Private Endpoint Connection. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param private_endpoint_connection_name: The PrivateEndpointConnection name. + :param private_endpoint_connection_name: The PrivateEndpointConnection name. 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. @@ -292,108 +389,104 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements 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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: 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 + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, namespace_name=namespace_name, private_endpoint_connection_name=private_endpoint_connection_name, api_version=api_version, - 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 = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}" + } @distributed_trace_async async def get( - self, - resource_group_name: str, - namespace_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> _models.PrivateEndpointConnection: """Gets a description for the specified Private Endpoint Connection. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param private_endpoint_connection_name: The PrivateEndpointConnection name. + :param private_endpoint_connection_name: The PrivateEndpointConnection name. 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.servicebus.v2021_06_01_preview.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_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'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -401,12 +494,13 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, 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.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/operations/_private_link_resources_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/operations/_private_link_resources_operations.py index aa5401e310a13..690504779f9c7 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/operations/_private_link_resources_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/operations/_private_link_resources_operations.py @@ -6,9 +6,17 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Optional, TypeVar -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -19,9 +27,15 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._private_link_resources_operations import build_get_request -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class PrivateLinkResourcesOperations: """ .. warning:: @@ -41,54 +55,53 @@ def __init__(self, *args, **kwargs) -> None: 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, - namespace_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, **kwargs: Any ) -> _models.PrivateLinkResourcesListResult: """Gets lists of resources that supports Privatelinks. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateLinkResourcesListResult, or the result of cls(response) + :return: PrivateLinkResourcesListResult or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.PrivateLinkResourcesListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateLinkResourcesListResult] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.PrivateLinkResourcesListResult] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -96,12 +109,13 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateLinkResourcesListResult', pipeline_response) + deserialized = self._deserialize("PrivateLinkResourcesListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateLinkResources"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateLinkResources" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/operations/_queues_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/operations/_queues_operations.py index d97a7cbc3044c..4b138de390fc6 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/operations/_queues_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/operations/_queues_operations.py @@ -6,10 +6,19 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,27 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._queues_operations import build_create_or_update_authorization_rule_request, build_create_or_update_request, build_delete_authorization_rule_request, build_delete_request, build_get_authorization_rule_request, build_get_request, build_list_authorization_rules_request, build_list_by_namespace_request, build_list_keys_request, build_regenerate_keys_request -T = TypeVar('T') +from ...operations._queues_operations import ( + build_create_or_update_authorization_rule_request, + build_create_or_update_request, + build_delete_authorization_rule_request, + build_delete_request, + build_get_authorization_rule_request, + build_get_request, + build_list_authorization_rules_request, + build_list_by_namespace_request, + build_list_keys_request, + build_regenerate_keys_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class QueuesOperations: """ .. warning:: @@ -43,70 +69,71 @@ def __init__(self, *args, **kwargs) -> None: 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_authorization_rules( - self, - resource_group_name: str, - namespace_name: str, - queue_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.SBAuthorizationRuleListResult]: + self, resource_group_name: str, namespace_name: str, queue_name: str, **kwargs: Any + ) -> AsyncIterable["_models.SBAuthorizationRule"]: """Gets all authorization rules for a queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of - cls(response) + :return: An iterator like instance of either SBAuthorizationRule or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRule] + :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', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRuleListResult] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.SBAuthorizationRuleListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_authorization_rules_request( resource_group_name=resource_group_name, namespace_name=namespace_name, queue_name=queue_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_authorization_rules.metadata['url'], + template_url=self.list_authorization_rules.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_authorization_rules_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - queue_name=queue_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -114,16 +141,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("SBAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -134,13 +159,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_authorization_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules"} # type: ignore + list_authorization_rules.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules" + } - @distributed_trace_async + @overload async def create_or_update_authorization_rule( self, resource_group_name: str, @@ -148,38 +173,119 @@ async def create_or_update_authorization_rule( queue_name: str, authorization_rule_name: str, parameters: _models.SBAuthorizationRule, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SBAuthorizationRule: """Creates an authorization rule for a queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: The shared access authorization rule. + :param parameters: The shared access authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBAuthorizationRule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates an authorization rule for a queue. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Required. + :type 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: SBAuthorizationRule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: Union[_models.SBAuthorizationRule, IO], + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates an authorization rule for a queue. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRule 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: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SBAuthorizationRule] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'SBAuthorizationRule') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBAuthorizationRule") request = build_create_or_update_authorization_rule_request( resource_group_name=resource_group_name, @@ -190,18 +296,18 @@ async def create_or_update_authorization_rule( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_authorization_rule.metadata['url'], + content=_content, + template_url=self.create_or_update_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -209,15 +315,16 @@ async def create_or_update_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}"} # type: ignore - + create_or_update_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}" + } @distributed_trace_async async def delete_authorization_rule( # pylint: disable=inconsistent-return-statements @@ -230,31 +337,35 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat ) -> None: """Deletes a queue authorization rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -262,18 +373,17 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_authorization_rule.metadata['url'], + template_url=self.delete_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -284,8 +394,9 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat if cls: return cls(pipeline_response, None, {}) - delete_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}"} # type: ignore - + delete_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}" + } @distributed_trace_async async def get_authorization_rule( @@ -298,31 +409,35 @@ async def get_authorization_rule( ) -> _models.SBAuthorizationRule: """Gets an authorization rule for a queue by rule name. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.SBAuthorizationRule] = kwargs.pop("cls", None) - request = build_get_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -330,18 +445,17 @@ async def get_authorization_rule( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_authorization_rule.metadata['url'], + template_url=self.get_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -349,15 +463,16 @@ async def get_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}"} # type: ignore - + get_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}" + } @distributed_trace_async async def list_keys( @@ -370,31 +485,35 @@ async def list_keys( ) -> _models.AccessKeys: """Primary and secondary connection strings to the queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.AccessKeys] = kwargs.pop("cls", None) - request = build_list_keys_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -402,18 +521,17 @@ async def list_keys( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata['url'], + 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 + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -421,17 +539,18 @@ async def list_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + deserialized = self._deserialize("AccessKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/ListKeys"} # type: ignore - + list_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/ListKeys" + } - @distributed_trace_async + @overload async def regenerate_keys( self, resource_group_name: str, @@ -439,39 +558,121 @@ async def regenerate_keys( queue_name: str, authorization_rule_name: str, parameters: _models.RegenerateAccessKeyParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.AccessKeys: """Regenerates the primary or secondary connection strings to the queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate the authorization rule. + :param parameters: Parameters supplied to regenerate the authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.RegenerateAccessKeyParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AccessKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AccessKeys: + """Regenerates the primary or secondary connection strings to the queue. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Required. + :type 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: AccessKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: Union[_models.RegenerateAccessKeyParameters, IO], + **kwargs: Any + ) -> _models.AccessKeys: + """Regenerates the primary or secondary connection strings to the queue. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Is either a model + type or a IO type. Required. + :type parameters: + ~azure.mgmt.servicebus.v2021_06_01_preview.models.RegenerateAccessKeyParameters 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: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AccessKeys] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RegenerateAccessKeyParameters") request = build_regenerate_keys_request( resource_group_name=resource_group_name, @@ -482,18 +683,18 @@ async def regenerate_keys( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_keys.metadata['url'], + content=_content, + template_url=self.regenerate_keys.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -501,15 +702,16 @@ async def regenerate_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + deserialized = self._deserialize("AccessKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/regenerateKeys"} # type: ignore - + regenerate_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/regenerateKeys" + } @distributed_trace def list_by_namespace( @@ -519,12 +721,12 @@ def list_by_namespace( skip: Optional[int] = None, top: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable[_models.SBQueueListResult]: + ) -> AsyncIterable["_models.SBQueue"]: """Gets the queues within a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :param skip: Skip is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skip @@ -534,53 +736,59 @@ def list_by_namespace( Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBQueueListResult or the result of cls(response) + :return: An iterator like instance of either SBQueue or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBQueueListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBQueue] + :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', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBQueueListResult] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.SBQueueListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_namespace_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, - api_version=api_version, skip=skip, top=top, - template_url=self.list_by_namespace.metadata['url'], + api_version=api_version, + template_url=self.list_by_namespace.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_by_namespace_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - skip=skip, - top=top, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -588,16 +796,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("SBQueueListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -608,49 +814,124 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_namespace.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues"} # type: ignore + list_by_namespace.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues" + } - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, namespace_name: str, queue_name: str, parameters: _models.SBQueue, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SBQueue: """Creates or updates a Service Bus queue. This operation is idempotent. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param parameters: Parameters supplied to create or update a queue resource. + :param parameters: Parameters supplied to create or update a queue resource. Required. :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBQueue + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBQueue or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBQueue: + """Creates or updates a Service Bus queue. This operation is idempotent. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param parameters: Parameters supplied to create or update a queue resource. Required. + :type 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: SBQueue or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + parameters: Union[_models.SBQueue, IO], + **kwargs: Any + ) -> _models.SBQueue: + """Creates or updates a Service Bus queue. This operation is idempotent. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param parameters: Parameters supplied to create or update a queue resource. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBQueue 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: SBQueue, or the result of cls(response) + :return: SBQueue or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBQueue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBQueue] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SBQueue] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'SBQueue') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBQueue") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -660,18 +941,18 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - 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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -679,67 +960,67 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBQueue', pipeline_response) + deserialized = self._deserialize("SBQueue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}"} # type: ignore - + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}" + } @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - queue_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, queue_name: str, **kwargs: Any ) -> None: """Deletes a queue from the specified namespace in a resource group. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, queue_name=queue_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -750,60 +1031,60 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}"} # type: ignore - + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}" + } @distributed_trace_async async def get( - self, - resource_group_name: str, - namespace_name: str, - queue_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, queue_name: str, **kwargs: Any ) -> _models.SBQueue: """Returns a description for the specified queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBQueue, or the result of cls(response) + :return: SBQueue or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBQueue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBQueue] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.SBQueue] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, queue_name=queue_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -811,12 +1092,13 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBQueue', pipeline_response) + deserialized = self._deserialize("SBQueue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/operations/_rules_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/operations/_rules_operations.py index 50be288b6037b..5c3aafa2d77fd 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/operations/_rules_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/operations/_rules_operations.py @@ -6,10 +6,19 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,21 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._rules_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_by_subscriptions_request -T = TypeVar('T') +from ...operations._rules_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_subscriptions_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class RulesOperations: """ .. warning:: @@ -43,7 +63,6 @@ def __init__(self, *args, **kwargs) -> None: 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_subscriptions( self, @@ -54,16 +73,16 @@ def list_by_subscriptions( skip: Optional[int] = None, top: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable[_models.RuleListResult]: + ) -> AsyncIterable["_models.Rule"]: """List all the rules within given topic-subscription. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str :param skip: Skip is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skip @@ -73,57 +92,61 @@ def list_by_subscriptions( Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RuleListResult or the result of cls(response) + :return: An iterator like instance of either Rule or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.RuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.Rule] + :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', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.RuleListResult] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.RuleListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscriptions_request( resource_group_name=resource_group_name, namespace_name=namespace_name, topic_name=topic_name, subscription_name=subscription_name, subscription_id=self._config.subscription_id, - api_version=api_version, skip=skip, top=top, - template_url=self.list_by_subscriptions.metadata['url'], + api_version=api_version, + template_url=self.list_by_subscriptions.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_by_subscriptions_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - topic_name=topic_name, - subscription_name=subscription_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - skip=skip, - top=top, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -131,16 +154,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("RuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -151,13 +172,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_subscriptions.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules"} # type: ignore + list_by_subscriptions.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules" + } - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, @@ -166,40 +187,127 @@ async def create_or_update( subscription_name: str, rule_name: str, parameters: _models.Rule, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.Rule: """Creates a new rule and updates an existing rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str - :param rule_name: The rule name. + :param rule_name: The rule name. Required. :type rule_name: str - :param parameters: Parameters supplied to create a rule. + :param parameters: Parameters supplied to create a rule. Required. :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.Rule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Rule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.Rule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Rule: + """Creates a new rule and updates an existing rule. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param rule_name: The rule name. Required. + :type rule_name: str + :param parameters: Parameters supplied to create a rule. Required. + :type 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: Rule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.Rule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + rule_name: str, + parameters: Union[_models.Rule, IO], + **kwargs: Any + ) -> _models.Rule: + """Creates a new rule and updates an existing rule. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param rule_name: The rule name. Required. + :type rule_name: str + :param parameters: Parameters supplied to create a rule. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.Rule 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: Rule, or the result of cls(response) + :return: Rule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.Rule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.Rule] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Rule] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'Rule') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Rule") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -211,18 +319,18 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - 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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -230,15 +338,16 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Rule', pipeline_response) + deserialized = self._deserialize("Rule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}"} # type: ignore - + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}" + } @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -252,33 +361,37 @@ async def delete( # pylint: disable=inconsistent-return-statements ) -> None: """Deletes an existing rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str - :param rule_name: The rule name. + :param rule_name: The rule name. Required. :type rule_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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -287,18 +400,17 @@ async def delete( # pylint: disable=inconsistent-return-statements rule_name=rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -309,8 +421,9 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}"} # type: ignore - + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}" + } @distributed_trace_async async def get( @@ -324,33 +437,37 @@ async def get( ) -> _models.Rule: """Retrieves the description for the specified rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str - :param rule_name: The rule name. + :param rule_name: The rule name. Required. :type rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Rule, or the result of cls(response) + :return: Rule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.Rule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Rule] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.Rule] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -359,18 +476,17 @@ async def get( rule_name=rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -378,12 +494,13 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Rule', pipeline_response) + deserialized = self._deserialize("Rule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/operations/_subscriptions_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/operations/_subscriptions_operations.py index 7c336657b705b..50f512b3fb2c9 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/operations/_subscriptions_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/operations/_subscriptions_operations.py @@ -6,10 +6,19 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,21 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._subscriptions_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_by_topic_request -T = TypeVar('T') +from ...operations._subscriptions_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_topic_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class SubscriptionsOperations: """ .. warning:: @@ -43,7 +63,6 @@ def __init__(self, *args, **kwargs) -> None: 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_topic( self, @@ -53,14 +72,14 @@ def list_by_topic( skip: Optional[int] = None, top: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable[_models.SBSubscriptionListResult]: + ) -> AsyncIterable["_models.SBSubscription"]: """List all the subscriptions under a specified topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str :param skip: Skip is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skip @@ -70,56 +89,60 @@ def list_by_topic( Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBSubscriptionListResult or the result of - cls(response) + :return: An iterator like instance of either SBSubscription or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBSubscriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBSubscription] + :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', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBSubscriptionListResult] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.SBSubscriptionListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_topic_request( resource_group_name=resource_group_name, namespace_name=namespace_name, topic_name=topic_name, subscription_id=self._config.subscription_id, - api_version=api_version, skip=skip, top=top, - template_url=self.list_by_topic.metadata['url'], + api_version=api_version, + template_url=self.list_by_topic.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_by_topic_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - topic_name=topic_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - skip=skip, - top=top, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -127,16 +150,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("SBSubscriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -147,13 +168,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_topic.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions"} # type: ignore + list_by_topic.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions" + } - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, @@ -161,38 +182,119 @@ async def create_or_update( topic_name: str, subscription_name: str, parameters: _models.SBSubscription, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SBSubscription: """Creates a topic subscription. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str - :param parameters: Parameters supplied to create a subscription resource. + :param parameters: Parameters supplied to create a subscription resource. Required. :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBSubscription + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBSubscription, or the result of cls(response) + :return: SBSubscription or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBSubscription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBSubscription: + """Creates a topic subscription. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param parameters: Parameters supplied to create a subscription resource. Required. + :type 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: SBSubscription or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBSubscription + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + parameters: Union[_models.SBSubscription, IO], + **kwargs: Any + ) -> _models.SBSubscription: + """Creates a topic subscription. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param parameters: Parameters supplied to create a subscription resource. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBSubscription 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: SBSubscription or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBSubscription + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBSubscription] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SBSubscription] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'SBSubscription') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBSubscription") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -203,18 +305,18 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - 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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -222,52 +324,52 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBSubscription', pipeline_response) + deserialized = self._deserialize("SBSubscription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}"} # type: ignore - + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}" + } @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - subscription_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, topic_name: str, subscription_name: str, **kwargs: Any ) -> None: """Deletes a subscription from the specified topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -275,18 +377,17 @@ async def delete( # pylint: disable=inconsistent-return-statements subscription_name=subscription_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -297,45 +398,45 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}"} # type: ignore - + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}" + } @distributed_trace_async async def get( - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - subscription_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, topic_name: str, subscription_name: str, **kwargs: Any ) -> _models.SBSubscription: """Returns a subscription description for the specified topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBSubscription, or the result of cls(response) + :return: SBSubscription or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBSubscription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBSubscription] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.SBSubscription] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -343,18 +444,17 @@ async def get( subscription_name=subscription_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -362,12 +462,13 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBSubscription', pipeline_response) + deserialized = self._deserialize("SBSubscription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/operations/_topics_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/operations/_topics_operations.py index c55bd895d94eb..c2911751d5708 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/operations/_topics_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/operations/_topics_operations.py @@ -6,10 +6,19 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,27 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._topics_operations import build_create_or_update_authorization_rule_request, build_create_or_update_request, build_delete_authorization_rule_request, build_delete_request, build_get_authorization_rule_request, build_get_request, build_list_authorization_rules_request, build_list_by_namespace_request, build_list_keys_request, build_regenerate_keys_request -T = TypeVar('T') +from ...operations._topics_operations import ( + build_create_or_update_authorization_rule_request, + build_create_or_update_request, + build_delete_authorization_rule_request, + build_delete_request, + build_get_authorization_rule_request, + build_get_request, + build_list_authorization_rules_request, + build_list_by_namespace_request, + build_list_keys_request, + build_regenerate_keys_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class TopicsOperations: """ .. warning:: @@ -43,70 +69,71 @@ def __init__(self, *args, **kwargs) -> None: 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_authorization_rules( - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.SBAuthorizationRuleListResult]: + self, resource_group_name: str, namespace_name: str, topic_name: str, **kwargs: Any + ) -> AsyncIterable["_models.SBAuthorizationRule"]: """Gets authorization rules for a topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of - cls(response) + :return: An iterator like instance of either SBAuthorizationRule or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRule] + :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', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRuleListResult] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.SBAuthorizationRuleListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_authorization_rules_request( resource_group_name=resource_group_name, namespace_name=namespace_name, topic_name=topic_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_authorization_rules.metadata['url'], + template_url=self.list_authorization_rules.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_authorization_rules_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - topic_name=topic_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -114,16 +141,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("SBAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -134,13 +159,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_authorization_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules"} # type: ignore + list_authorization_rules.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules" + } - @distributed_trace_async + @overload async def create_or_update_authorization_rule( self, resource_group_name: str, @@ -148,38 +173,119 @@ async def create_or_update_authorization_rule( topic_name: str, authorization_rule_name: str, parameters: _models.SBAuthorizationRule, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SBAuthorizationRule: """Creates an authorization rule for the specified topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: The shared access authorization rule. + :param parameters: The shared access authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBAuthorizationRule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates an authorization rule for the specified topic. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Required. + :type 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: SBAuthorizationRule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: Union[_models.SBAuthorizationRule, IO], + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates an authorization rule for the specified topic. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRule 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: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SBAuthorizationRule] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'SBAuthorizationRule') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBAuthorizationRule") request = build_create_or_update_authorization_rule_request( resource_group_name=resource_group_name, @@ -190,18 +296,18 @@ async def create_or_update_authorization_rule( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_authorization_rule.metadata['url'], + content=_content, + template_url=self.create_or_update_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -209,15 +315,16 @@ async def create_or_update_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}"} # type: ignore - + create_or_update_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}" + } @distributed_trace_async async def get_authorization_rule( @@ -230,31 +337,35 @@ async def get_authorization_rule( ) -> _models.SBAuthorizationRule: """Returns the specified authorization rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.SBAuthorizationRule] = kwargs.pop("cls", None) - request = build_get_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -262,18 +373,17 @@ async def get_authorization_rule( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_authorization_rule.metadata['url'], + template_url=self.get_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -281,15 +391,16 @@ async def get_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}"} # type: ignore - + get_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}" + } @distributed_trace_async async def delete_authorization_rule( # pylint: disable=inconsistent-return-statements @@ -302,31 +413,35 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat ) -> None: """Deletes a topic authorization rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -334,18 +449,17 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_authorization_rule.metadata['url'], + template_url=self.delete_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -356,8 +470,9 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat if cls: return cls(pipeline_response, None, {}) - delete_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}"} # type: ignore - + delete_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}" + } @distributed_trace_async async def list_keys( @@ -370,31 +485,35 @@ async def list_keys( ) -> _models.AccessKeys: """Gets the primary and secondary connection strings for the topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.AccessKeys] = kwargs.pop("cls", None) - request = build_list_keys_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -402,18 +521,17 @@ async def list_keys( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata['url'], + 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 + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -421,17 +539,18 @@ async def list_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + deserialized = self._deserialize("AccessKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/ListKeys"} # type: ignore - + list_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/ListKeys" + } - @distributed_trace_async + @overload async def regenerate_keys( self, resource_group_name: str, @@ -439,39 +558,121 @@ async def regenerate_keys( topic_name: str, authorization_rule_name: str, parameters: _models.RegenerateAccessKeyParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.AccessKeys: """Regenerates primary or secondary connection strings for the topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate the authorization rule. + :param parameters: Parameters supplied to regenerate the authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.RegenerateAccessKeyParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AccessKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AccessKeys: + """Regenerates primary or secondary connection strings for the topic. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Required. + :type 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: AccessKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: Union[_models.RegenerateAccessKeyParameters, IO], + **kwargs: Any + ) -> _models.AccessKeys: + """Regenerates primary or secondary connection strings for the topic. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Is either a model + type or a IO type. Required. + :type parameters: + ~azure.mgmt.servicebus.v2021_06_01_preview.models.RegenerateAccessKeyParameters 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: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AccessKeys] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RegenerateAccessKeyParameters") request = build_regenerate_keys_request( resource_group_name=resource_group_name, @@ -482,18 +683,18 @@ async def regenerate_keys( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_keys.metadata['url'], + content=_content, + template_url=self.regenerate_keys.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -501,15 +702,16 @@ async def regenerate_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + deserialized = self._deserialize("AccessKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/regenerateKeys"} # type: ignore - + regenerate_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/regenerateKeys" + } @distributed_trace def list_by_namespace( @@ -519,12 +721,12 @@ def list_by_namespace( skip: Optional[int] = None, top: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable[_models.SBTopicListResult]: + ) -> AsyncIterable["_models.SBTopic"]: """Gets all the topics in a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :param skip: Skip is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skip @@ -534,53 +736,59 @@ def list_by_namespace( Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBTopicListResult or the result of cls(response) + :return: An iterator like instance of either SBTopic or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBTopicListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBTopic] + :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', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBTopicListResult] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.SBTopicListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_namespace_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, - api_version=api_version, skip=skip, top=top, - template_url=self.list_by_namespace.metadata['url'], + api_version=api_version, + template_url=self.list_by_namespace.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_by_namespace_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - skip=skip, - top=top, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -588,16 +796,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("SBTopicListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -608,49 +814,124 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_namespace.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics"} # type: ignore + list_by_namespace.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics" + } - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, namespace_name: str, topic_name: str, parameters: _models.SBTopic, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SBTopic: """Creates a topic in the specified namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param parameters: Parameters supplied to create a topic resource. + :param parameters: Parameters supplied to create a topic resource. Required. :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBTopic + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBTopic or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBTopic + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBTopic: + """Creates a topic in the specified namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param parameters: Parameters supplied to create a topic resource. Required. + :type 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: SBTopic or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBTopic + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + parameters: Union[_models.SBTopic, IO], + **kwargs: Any + ) -> _models.SBTopic: + """Creates a topic in the specified namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param parameters: Parameters supplied to create a topic resource. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBTopic 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: SBTopic, or the result of cls(response) + :return: SBTopic or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBTopic - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBTopic] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SBTopic] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'SBTopic') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBTopic") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -660,18 +941,18 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - 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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -679,67 +960,67 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBTopic', pipeline_response) + deserialized = self._deserialize("SBTopic", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}"} # type: ignore - + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}" + } @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, topic_name: str, **kwargs: Any ) -> None: """Deletes a topic from the specified namespace and resource group. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, topic_name=topic_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -750,60 +1031,60 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}"} # type: ignore - + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}" + } @distributed_trace_async async def get( - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, topic_name: str, **kwargs: Any ) -> _models.SBTopic: """Returns a description for the specified topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBTopic, or the result of cls(response) + :return: SBTopic or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBTopic - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBTopic] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.SBTopic] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, topic_name=topic_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -811,12 +1092,13 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBTopic', pipeline_response) + deserialized = self._deserialize("SBTopic", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/models/__init__.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/models/__init__.py index 0c388e2dc7f2b..6cef0d97b01f6 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/models/__init__.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/models/__init__.py @@ -62,102 +62,100 @@ from ._models_py3 import UserAssignedIdentity from ._models_py3 import UserAssignedIdentityProperties - -from ._service_bus_management_client_enums import ( - AccessRights, - CreatedByType, - DefaultAction, - EndPointProvisioningState, - EntityStatus, - FilterType, - KeyType, - ManagedServiceIdentityType, - MigrationConfigurationName, - NetworkRuleIPAction, - PrivateLinkConnectionStatus, - ProvisioningStateDR, - PublicNetworkAccessFlag, - RoleDisasterRecovery, - SkuName, - SkuTier, - UnavailableReason, -) +from ._service_bus_management_client_enums import AccessRights +from ._service_bus_management_client_enums import CreatedByType +from ._service_bus_management_client_enums import DefaultAction +from ._service_bus_management_client_enums import EndPointProvisioningState +from ._service_bus_management_client_enums import EntityStatus +from ._service_bus_management_client_enums import FilterType +from ._service_bus_management_client_enums import KeyType +from ._service_bus_management_client_enums import ManagedServiceIdentityType +from ._service_bus_management_client_enums import MigrationConfigurationName +from ._service_bus_management_client_enums import NetworkRuleIPAction +from ._service_bus_management_client_enums import PrivateLinkConnectionStatus +from ._service_bus_management_client_enums import ProvisioningStateDR +from ._service_bus_management_client_enums import PublicNetworkAccessFlag +from ._service_bus_management_client_enums import RoleDisasterRecovery +from ._service_bus_management_client_enums import SkuName +from ._service_bus_management_client_enums import SkuTier +from ._service_bus_management_client_enums import UnavailableReason from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'AccessKeys', - 'Action', - 'ArmDisasterRecovery', - 'ArmDisasterRecoveryListResult', - 'CheckNameAvailability', - 'CheckNameAvailabilityResult', - 'ConnectionState', - 'CorrelationFilter', - 'Encryption', - 'ErrorAdditionalInfo', - 'ErrorResponse', - 'ErrorResponseError', - 'FailoverProperties', - 'Identity', - 'KeyVaultProperties', - 'MessageCountDetails', - 'MigrationConfigListResult', - 'MigrationConfigProperties', - 'NWRuleSetIpRules', - 'NWRuleSetVirtualNetworkRules', - 'NetworkRuleSet', - 'NetworkRuleSetListResult', - 'Operation', - 'OperationDisplay', - 'OperationListResult', - 'PrivateEndpoint', - 'PrivateEndpointConnection', - 'PrivateEndpointConnectionListResult', - 'PrivateLinkResource', - 'PrivateLinkResourcesListResult', - 'RegenerateAccessKeyParameters', - 'Resource', - 'ResourceNamespacePatch', - 'Rule', - 'RuleListResult', - 'SBAuthorizationRule', - 'SBAuthorizationRuleListResult', - 'SBClientAffineProperties', - 'SBNamespace', - 'SBNamespaceListResult', - 'SBNamespaceUpdateParameters', - 'SBQueue', - 'SBQueueListResult', - 'SBSku', - 'SBSubscription', - 'SBSubscriptionListResult', - 'SBTopic', - 'SBTopicListResult', - 'SqlFilter', - 'SqlRuleAction', - 'Subnet', - 'SystemData', - 'TrackedResource', - 'UserAssignedIdentity', - 'UserAssignedIdentityProperties', - 'AccessRights', - 'CreatedByType', - 'DefaultAction', - 'EndPointProvisioningState', - 'EntityStatus', - 'FilterType', - 'KeyType', - 'ManagedServiceIdentityType', - 'MigrationConfigurationName', - 'NetworkRuleIPAction', - 'PrivateLinkConnectionStatus', - 'ProvisioningStateDR', - 'PublicNetworkAccessFlag', - 'RoleDisasterRecovery', - 'SkuName', - 'SkuTier', - 'UnavailableReason', + "AccessKeys", + "Action", + "ArmDisasterRecovery", + "ArmDisasterRecoveryListResult", + "CheckNameAvailability", + "CheckNameAvailabilityResult", + "ConnectionState", + "CorrelationFilter", + "Encryption", + "ErrorAdditionalInfo", + "ErrorResponse", + "ErrorResponseError", + "FailoverProperties", + "Identity", + "KeyVaultProperties", + "MessageCountDetails", + "MigrationConfigListResult", + "MigrationConfigProperties", + "NWRuleSetIpRules", + "NWRuleSetVirtualNetworkRules", + "NetworkRuleSet", + "NetworkRuleSetListResult", + "Operation", + "OperationDisplay", + "OperationListResult", + "PrivateEndpoint", + "PrivateEndpointConnection", + "PrivateEndpointConnectionListResult", + "PrivateLinkResource", + "PrivateLinkResourcesListResult", + "RegenerateAccessKeyParameters", + "Resource", + "ResourceNamespacePatch", + "Rule", + "RuleListResult", + "SBAuthorizationRule", + "SBAuthorizationRuleListResult", + "SBClientAffineProperties", + "SBNamespace", + "SBNamespaceListResult", + "SBNamespaceUpdateParameters", + "SBQueue", + "SBQueueListResult", + "SBSku", + "SBSubscription", + "SBSubscriptionListResult", + "SBTopic", + "SBTopicListResult", + "SqlFilter", + "SqlRuleAction", + "Subnet", + "SystemData", + "TrackedResource", + "UserAssignedIdentity", + "UserAssignedIdentityProperties", + "AccessRights", + "CreatedByType", + "DefaultAction", + "EndPointProvisioningState", + "EntityStatus", + "FilterType", + "KeyType", + "ManagedServiceIdentityType", + "MigrationConfigurationName", + "NetworkRuleIPAction", + "PrivateLinkConnectionStatus", + "ProvisioningStateDR", + "PublicNetworkAccessFlag", + "RoleDisasterRecovery", + "SkuName", + "SkuTier", + "UnavailableReason", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/models/_models_py3.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/models/_models_py3.py index 9e3cdc61ff724..1a2a133a4b23d 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/models/_models_py3.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_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,17 +8,22 @@ # -------------------------------------------------------------------------- import datetime +import sys from typing import Dict, List, Optional, TYPE_CHECKING, Union -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from ... import _serialization + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - import __init__ as _models + from .. import models as _models -class AccessKeys(msrest.serialization.Model): +class AccessKeys(_serialization.Model): """Namespace/ServiceBus Connection String. Variables are only populated by the server, and will be ignored when sending a request. @@ -45,32 +51,28 @@ class AccessKeys(msrest.serialization.Model): """ _validation = { - 'primary_connection_string': {'readonly': True}, - 'secondary_connection_string': {'readonly': True}, - 'alias_primary_connection_string': {'readonly': True}, - 'alias_secondary_connection_string': {'readonly': True}, - 'primary_key': {'readonly': True}, - 'secondary_key': {'readonly': True}, - 'key_name': {'readonly': True}, + "primary_connection_string": {"readonly": True}, + "secondary_connection_string": {"readonly": True}, + "alias_primary_connection_string": {"readonly": True}, + "alias_secondary_connection_string": {"readonly": True}, + "primary_key": {"readonly": True}, + "secondary_key": {"readonly": True}, + "key_name": {"readonly": True}, } _attribute_map = { - 'primary_connection_string': {'key': 'primaryConnectionString', 'type': 'str'}, - 'secondary_connection_string': {'key': 'secondaryConnectionString', 'type': 'str'}, - 'alias_primary_connection_string': {'key': 'aliasPrimaryConnectionString', 'type': 'str'}, - 'alias_secondary_connection_string': {'key': 'aliasSecondaryConnectionString', 'type': 'str'}, - 'primary_key': {'key': 'primaryKey', 'type': 'str'}, - 'secondary_key': {'key': 'secondaryKey', 'type': 'str'}, - 'key_name': {'key': 'keyName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - """ - """ - super(AccessKeys, self).__init__(**kwargs) + "primary_connection_string": {"key": "primaryConnectionString", "type": "str"}, + "secondary_connection_string": {"key": "secondaryConnectionString", "type": "str"}, + "alias_primary_connection_string": {"key": "aliasPrimaryConnectionString", "type": "str"}, + "alias_secondary_connection_string": {"key": "aliasSecondaryConnectionString", "type": "str"}, + "primary_key": {"key": "primaryKey", "type": "str"}, + "secondary_key": {"key": "secondaryKey", "type": "str"}, + "key_name": {"key": "keyName", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.primary_connection_string = None self.secondary_connection_string = None self.alias_primary_connection_string = None @@ -80,7 +82,7 @@ def __init__( self.key_name = None -class Action(msrest.serialization.Model): +class Action(_serialization.Model): """Represents the filter actions which are allowed for the transformation of a message that have been matched by a filter expression. :ivar sql_expression: SQL expression. e.g. MyProperty='ABC'. @@ -94,9 +96,9 @@ class Action(msrest.serialization.Model): """ _attribute_map = { - 'sql_expression': {'key': 'sqlExpression', 'type': 'str'}, - 'compatibility_level': {'key': 'compatibilityLevel', 'type': 'int'}, - 'requires_preprocessing': {'key': 'requiresPreprocessing', 'type': 'bool'}, + "sql_expression": {"key": "sqlExpression", "type": "str"}, + "compatibility_level": {"key": "compatibilityLevel", "type": "int"}, + "requires_preprocessing": {"key": "requiresPreprocessing", "type": "bool"}, } def __init__( @@ -104,7 +106,7 @@ def __init__( *, sql_expression: Optional[str] = None, compatibility_level: Optional[int] = None, - requires_preprocessing: Optional[bool] = True, + requires_preprocessing: bool = True, **kwargs ): """ @@ -117,13 +119,13 @@ def __init__( preprocessing. :paramtype requires_preprocessing: bool """ - super(Action, self).__init__(**kwargs) + super().__init__(**kwargs) self.sql_expression = sql_expression self.compatibility_level = compatibility_level self.requires_preprocessing = requires_preprocessing -class Resource(msrest.serialization.Model): +class Resource(_serialization.Model): """The Resource definition for other than namespace. Variables are only populated by the server, and will be ignored when sending a request. @@ -137,24 +139,20 @@ class Resource(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(Resource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -175,11 +173,11 @@ class ArmDisasterRecovery(Resource): :vartype system_data: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SystemData :ivar provisioning_state: Provisioning state of the Alias(Disaster Recovery configuration) - possible values 'Accepted' or 'Succeeded' or 'Failed'. Known values are: "Accepted", - "Succeeded", "Failed". + "Succeeded", and "Failed". :vartype provisioning_state: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.ProvisioningStateDR :ivar pending_replication_operations_count: Number of entities pending to be replicated. - :vartype pending_replication_operations_count: long + :vartype pending_replication_operations_count: int :ivar partner_namespace: ARM Id of the Primary/Secondary eventhub namespace name, which is part of GEO DR pairing. :vartype partner_namespace: str @@ -187,39 +185,33 @@ class ArmDisasterRecovery(Resource): pairing. :vartype alternate_name: str :ivar role: role of namespace in GEO DR - possible values 'Primary' or 'PrimaryNotReplicating' - or 'Secondary'. Known values are: "Primary", "PrimaryNotReplicating", "Secondary". + or 'Secondary'. Known values are: "Primary", "PrimaryNotReplicating", and "Secondary". :vartype role: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.RoleDisasterRecovery """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'pending_replication_operations_count': {'readonly': True}, - 'role': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "pending_replication_operations_count": {"readonly": True}, + "role": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'pending_replication_operations_count': {'key': 'properties.pendingReplicationOperationsCount', 'type': 'long'}, - 'partner_namespace': {'key': 'properties.partnerNamespace', 'type': 'str'}, - 'alternate_name': {'key': 'properties.alternateName', 'type': 'str'}, - 'role': {'key': 'properties.role', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "pending_replication_operations_count": {"key": "properties.pendingReplicationOperationsCount", "type": "int"}, + "partner_namespace": {"key": "properties.partnerNamespace", "type": "str"}, + "alternate_name": {"key": "properties.alternateName", "type": "str"}, + "role": {"key": "properties.role", "type": "str"}, } - def __init__( - self, - *, - partner_namespace: Optional[str] = None, - alternate_name: Optional[str] = None, - **kwargs - ): + def __init__(self, *, partner_namespace: Optional[str] = None, alternate_name: Optional[str] = None, **kwargs): """ :keyword partner_namespace: ARM Id of the Primary/Secondary eventhub namespace name, which is part of GEO DR pairing. @@ -228,7 +220,7 @@ def __init__( pairing. :paramtype alternate_name: str """ - super(ArmDisasterRecovery, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.provisioning_state = None self.pending_replication_operations_count = None @@ -237,7 +229,7 @@ def __init__( self.role = None -class ArmDisasterRecoveryListResult(msrest.serialization.Model): +class ArmDisasterRecoveryListResult(_serialization.Model): """The result of the List Alias(Disaster Recovery configuration) operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -250,65 +242,55 @@ class ArmDisasterRecoveryListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[ArmDisasterRecovery]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ArmDisasterRecovery]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["_models.ArmDisasterRecovery"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.ArmDisasterRecovery"]] = None, **kwargs): """ :keyword value: List of Alias(Disaster Recovery configurations). :paramtype value: list[~azure.mgmt.servicebus.v2021_06_01_preview.models.ArmDisasterRecovery] """ - super(ArmDisasterRecoveryListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class CheckNameAvailability(msrest.serialization.Model): +class CheckNameAvailability(_serialization.Model): """Description of a Check Name availability request properties. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The Name to check the namespace name availability and The namespace name - can contain only letters, numbers, and hyphens. The namespace must start with a letter, and it - must end with a letter or number. + :ivar name: The Name to check the namespace name availability and The namespace name can + contain only letters, numbers, and hyphens. The namespace must start with a letter, and it must + end with a letter or number. 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 to check the namespace name availability and The namespace - name can contain only letters, numbers, and hyphens. The namespace must start with a letter, - and it must end with a letter or number. + :keyword name: The Name to check the namespace name availability and The namespace name can + contain only letters, numbers, and hyphens. The namespace must start with a letter, and it must + end with a letter or number. Required. :paramtype name: str """ - super(CheckNameAvailability, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class CheckNameAvailabilityResult(msrest.serialization.Model): +class CheckNameAvailabilityResult(_serialization.Model): """Description of a Check Name availability request properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -319,19 +301,19 @@ class CheckNameAvailabilityResult(msrest.serialization.Model): available; otherwise, false. :vartype name_available: bool :ivar reason: The reason for unavailability of a namespace. Known values are: "None", - "InvalidName", "SubscriptionIsDisabled", "NameInUse", "NameInLockdown", + "InvalidName", "SubscriptionIsDisabled", "NameInUse", "NameInLockdown", and "TooManyNamespaceInCurrentSubscription". :vartype reason: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.UnavailableReason """ _validation = { - 'message': {'readonly': True}, + "message": {"readonly": True}, } _attribute_map = { - 'message': {'key': 'message', 'type': 'str'}, - '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"}, } def __init__( @@ -346,21 +328,21 @@ def __init__( available; otherwise, false. :paramtype name_available: bool :keyword reason: The reason for unavailability of a namespace. Known values are: "None", - "InvalidName", "SubscriptionIsDisabled", "NameInUse", "NameInLockdown", + "InvalidName", "SubscriptionIsDisabled", "NameInUse", "NameInLockdown", and "TooManyNamespaceInCurrentSubscription". :paramtype reason: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.UnavailableReason """ - super(CheckNameAvailabilityResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.message = None self.name_available = name_available self.reason = reason -class ConnectionState(msrest.serialization.Model): +class ConnectionState(_serialization.Model): """ConnectionState information. :ivar status: Status of the connection. Known values are: "Pending", "Approved", "Rejected", - "Disconnected". + and "Disconnected". :vartype status: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.PrivateLinkConnectionStatus :ivar description: Description of the connection state. @@ -368,8 +350,8 @@ class ConnectionState(msrest.serialization.Model): """ _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, + "status": {"key": "status", "type": "str"}, + "description": {"key": "description", "type": "str"}, } def __init__( @@ -381,18 +363,18 @@ def __init__( ): """ :keyword status: Status of the connection. Known values are: "Pending", "Approved", "Rejected", - "Disconnected". + and "Disconnected". :paramtype status: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.PrivateLinkConnectionStatus :keyword description: Description of the connection state. :paramtype description: str """ - super(ConnectionState, self).__init__(**kwargs) + super().__init__(**kwargs) self.status = status self.description = description -class CorrelationFilter(msrest.serialization.Model): +class CorrelationFilter(_serialization.Model): """Represents the correlation filter expression. :ivar properties: dictionary object for custom filters. @@ -419,16 +401,16 @@ class CorrelationFilter(msrest.serialization.Model): """ _attribute_map = { - 'properties': {'key': 'properties', 'type': '{str}'}, - 'correlation_id': {'key': 'correlationId', 'type': 'str'}, - 'message_id': {'key': 'messageId', 'type': 'str'}, - 'to': {'key': 'to', 'type': 'str'}, - 'reply_to': {'key': 'replyTo', 'type': 'str'}, - 'label': {'key': 'label', 'type': 'str'}, - 'session_id': {'key': 'sessionId', 'type': 'str'}, - 'reply_to_session_id': {'key': 'replyToSessionId', 'type': 'str'}, - 'content_type': {'key': 'contentType', 'type': 'str'}, - 'requires_preprocessing': {'key': 'requiresPreprocessing', 'type': 'bool'}, + "properties": {"key": "properties", "type": "{str}"}, + "correlation_id": {"key": "correlationId", "type": "str"}, + "message_id": {"key": "messageId", "type": "str"}, + "to": {"key": "to", "type": "str"}, + "reply_to": {"key": "replyTo", "type": "str"}, + "label": {"key": "label", "type": "str"}, + "session_id": {"key": "sessionId", "type": "str"}, + "reply_to_session_id": {"key": "replyToSessionId", "type": "str"}, + "content_type": {"key": "contentType", "type": "str"}, + "requires_preprocessing": {"key": "requiresPreprocessing", "type": "bool"}, } def __init__( @@ -443,7 +425,7 @@ def __init__( session_id: Optional[str] = None, reply_to_session_id: Optional[str] = None, content_type: Optional[str] = None, - requires_preprocessing: Optional[bool] = True, + requires_preprocessing: bool = True, **kwargs ): """ @@ -469,7 +451,7 @@ def __init__( preprocessing. :paramtype requires_preprocessing: bool """ - super(CorrelationFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties self.correlation_id = correlation_id self.message_id = message_id @@ -482,14 +464,13 @@ def __init__( self.requires_preprocessing = requires_preprocessing -class Encryption(msrest.serialization.Model): +class Encryption(_serialization.Model): """Properties to configure Encryption. :ivar key_vault_properties: Properties of KeyVault. :vartype key_vault_properties: list[~azure.mgmt.servicebus.v2021_06_01_preview.models.KeyVaultProperties] - :ivar key_source: Enumerates the possible value of keySource for Encryption. The only - acceptable values to pass in are None and "Microsoft.KeyVault". The default value is + :ivar key_source: Enumerates the possible value of keySource for Encryption. Default value is "Microsoft.KeyVault". :vartype key_source: str :ivar require_infrastructure_encryption: Enable Infrastructure Encryption (Double Encryption). @@ -497,16 +478,16 @@ class Encryption(msrest.serialization.Model): """ _attribute_map = { - 'key_vault_properties': {'key': 'keyVaultProperties', 'type': '[KeyVaultProperties]'}, - 'key_source': {'key': 'keySource', 'type': 'str'}, - 'require_infrastructure_encryption': {'key': 'requireInfrastructureEncryption', 'type': 'bool'}, + "key_vault_properties": {"key": "keyVaultProperties", "type": "[KeyVaultProperties]"}, + "key_source": {"key": "keySource", "type": "str"}, + "require_infrastructure_encryption": {"key": "requireInfrastructureEncryption", "type": "bool"}, } def __init__( self, *, key_vault_properties: Optional[List["_models.KeyVaultProperties"]] = None, - key_source: Optional[str] = "Microsoft.KeyVault", + key_source: Literal["Microsoft.KeyVault"] = "Microsoft.KeyVault", require_infrastructure_encryption: Optional[bool] = None, **kwargs ): @@ -514,21 +495,20 @@ def __init__( :keyword key_vault_properties: Properties of KeyVault. :paramtype key_vault_properties: list[~azure.mgmt.servicebus.v2021_06_01_preview.models.KeyVaultProperties] - :keyword key_source: Enumerates the possible value of keySource for Encryption. The only - acceptable values to pass in are None and "Microsoft.KeyVault". The default value is - "Microsoft.KeyVault". + :keyword key_source: Enumerates the possible value of keySource for Encryption. Default value + is "Microsoft.KeyVault". :paramtype key_source: str :keyword require_infrastructure_encryption: Enable Infrastructure Encryption (Double Encryption). :paramtype require_infrastructure_encryption: bool """ - super(Encryption, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_vault_properties = key_vault_properties self.key_source = key_source self.require_infrastructure_encryption = require_infrastructure_encryption -class ErrorAdditionalInfo(msrest.serialization.Model): +class ErrorAdditionalInfo(_serialization.Model): """The resource management error additional info. Variables are only populated by the server, and will be ignored when sending a request. @@ -536,31 +516,27 @@ class ErrorAdditionalInfo(msrest.serialization.Model): :ivar type: The additional info type. :vartype type: str :ivar info: The additional info. - :vartype info: any + :vartype info: JSON """ _validation = { - 'type': {'readonly': True}, - 'info': {'readonly': True}, + "type": {"readonly": True}, + "info": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'info': {'key': 'info', 'type': 'object'}, + "type": {"key": "type", "type": "str"}, + "info": {"key": "info", "type": "object"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorAdditionalInfo, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.type = None self.info = None -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_serialization.Model): """The resource management error response. :ivar error: The error object. @@ -568,24 +544,19 @@ class ErrorResponse(msrest.serialization.Model): """ _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorResponseError'}, + "error": {"key": "error", "type": "ErrorResponseError"}, } - def __init__( - self, - *, - error: Optional["_models.ErrorResponseError"] = None, - **kwargs - ): + def __init__(self, *, error: Optional["_models.ErrorResponseError"] = None, **kwargs): """ :keyword error: The error object. :paramtype error: ~azure.mgmt.servicebus.v2021_06_01_preview.models.ErrorResponseError """ - super(ErrorResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.error = error -class ErrorResponseError(msrest.serialization.Model): +class ErrorResponseError(_serialization.Model): """The error object. Variables are only populated by the server, and will be ignored when sending a request. @@ -604,28 +575,24 @@ class ErrorResponseError(msrest.serialization.Model): """ _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - 'details': {'readonly': True}, - 'additional_info': {'readonly': True}, + "code": {"readonly": True}, + "message": {"readonly": True}, + "target": {"readonly": True}, + "details": {"readonly": True}, + "additional_info": {"readonly": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ErrorResponse]'}, - 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[ErrorResponse]"}, + "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorResponseError, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.code = None self.message = None self.target = None @@ -633,7 +600,7 @@ def __init__( self.additional_info = None -class FailoverProperties(msrest.serialization.Model): +class FailoverProperties(_serialization.Model): """Safe failover is to indicate the service should wait for pending replication to finish before switching to the secondary. :ivar is_safe_failover: Safe failover is to indicate the service should wait for pending @@ -642,25 +609,20 @@ class FailoverProperties(msrest.serialization.Model): """ _attribute_map = { - 'is_safe_failover': {'key': 'properties.IsSafeFailover', 'type': 'bool'}, + "is_safe_failover": {"key": "properties.IsSafeFailover", "type": "bool"}, } - def __init__( - self, - *, - is_safe_failover: Optional[bool] = None, - **kwargs - ): + def __init__(self, *, is_safe_failover: Optional[bool] = None, **kwargs): """ :keyword is_safe_failover: Safe failover is to indicate the service should wait for pending replication to finish before switching to the secondary. :paramtype is_safe_failover: bool """ - super(FailoverProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.is_safe_failover = is_safe_failover -class Identity(msrest.serialization.Model): +class Identity(_serialization.Model): """Properties to configure User Assigned Identities for Bring your Own Keys. Variables are only populated by the server, and will be ignored when sending a request. @@ -670,7 +632,7 @@ class Identity(msrest.serialization.Model): :ivar tenant_id: TenantId from the KeyVault. :vartype tenant_id: str :ivar type: Type of managed service identity. Known values are: "SystemAssigned", - "UserAssigned", "SystemAssigned, UserAssigned", "None". + "UserAssigned", "SystemAssigned, UserAssigned", and "None". :vartype type: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.ManagedServiceIdentityType :ivar user_assigned_identities: Properties for User Assigned Identities. @@ -679,15 +641,15 @@ class Identity(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': '{UserAssignedIdentity}'}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "user_assigned_identities": {"key": "userAssignedIdentities", "type": "{UserAssignedIdentity}"}, } def __init__( @@ -699,21 +661,21 @@ def __init__( ): """ :keyword type: Type of managed service identity. Known values are: "SystemAssigned", - "UserAssigned", "SystemAssigned, UserAssigned", "None". + "UserAssigned", "SystemAssigned, UserAssigned", and "None". :paramtype type: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.ManagedServiceIdentityType :keyword user_assigned_identities: Properties for User Assigned Identities. :paramtype user_assigned_identities: dict[str, ~azure.mgmt.servicebus.v2021_06_01_preview.models.UserAssignedIdentity] """ - super(Identity, 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 KeyVaultProperties(msrest.serialization.Model): +class KeyVaultProperties(_serialization.Model): """Properties to configure keyVault Properties. :ivar key_name: Name of the Key from KeyVault. @@ -728,10 +690,10 @@ class KeyVaultProperties(msrest.serialization.Model): """ _attribute_map = { - 'key_name': {'key': 'keyName', 'type': 'str'}, - 'key_vault_uri': {'key': 'keyVaultUri', 'type': 'str'}, - 'key_version': {'key': 'keyVersion', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'UserAssignedIdentityProperties'}, + "key_name": {"key": "keyName", "type": "str"}, + "key_vault_uri": {"key": "keyVaultUri", "type": "str"}, + "key_version": {"key": "keyVersion", "type": "str"}, + "identity": {"key": "identity", "type": "UserAssignedIdentityProperties"}, } def __init__( @@ -754,54 +716,50 @@ def __init__( :paramtype identity: ~azure.mgmt.servicebus.v2021_06_01_preview.models.UserAssignedIdentityProperties """ - super(KeyVaultProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_name = key_name self.key_vault_uri = key_vault_uri self.key_version = key_version self.identity = identity -class MessageCountDetails(msrest.serialization.Model): +class MessageCountDetails(_serialization.Model): """Message Count Details. Variables are only populated by the server, and will be ignored when sending a request. :ivar active_message_count: Number of active messages in the queue, topic, or subscription. - :vartype active_message_count: long + :vartype active_message_count: int :ivar dead_letter_message_count: Number of messages that are dead lettered. - :vartype dead_letter_message_count: long + :vartype dead_letter_message_count: int :ivar scheduled_message_count: Number of scheduled messages. - :vartype scheduled_message_count: long + :vartype scheduled_message_count: int :ivar transfer_message_count: Number of messages transferred to another queue, topic, or subscription. - :vartype transfer_message_count: long + :vartype transfer_message_count: int :ivar transfer_dead_letter_message_count: Number of messages transferred into dead letters. - :vartype transfer_dead_letter_message_count: long + :vartype transfer_dead_letter_message_count: int """ _validation = { - 'active_message_count': {'readonly': True}, - 'dead_letter_message_count': {'readonly': True}, - 'scheduled_message_count': {'readonly': True}, - 'transfer_message_count': {'readonly': True}, - 'transfer_dead_letter_message_count': {'readonly': True}, + "active_message_count": {"readonly": True}, + "dead_letter_message_count": {"readonly": True}, + "scheduled_message_count": {"readonly": True}, + "transfer_message_count": {"readonly": True}, + "transfer_dead_letter_message_count": {"readonly": True}, } _attribute_map = { - 'active_message_count': {'key': 'activeMessageCount', 'type': 'long'}, - 'dead_letter_message_count': {'key': 'deadLetterMessageCount', 'type': 'long'}, - 'scheduled_message_count': {'key': 'scheduledMessageCount', 'type': 'long'}, - 'transfer_message_count': {'key': 'transferMessageCount', 'type': 'long'}, - 'transfer_dead_letter_message_count': {'key': 'transferDeadLetterMessageCount', 'type': 'long'}, + "active_message_count": {"key": "activeMessageCount", "type": "int"}, + "dead_letter_message_count": {"key": "deadLetterMessageCount", "type": "int"}, + "scheduled_message_count": {"key": "scheduledMessageCount", "type": "int"}, + "transfer_message_count": {"key": "transferMessageCount", "type": "int"}, + "transfer_dead_letter_message_count": {"key": "transferDeadLetterMessageCount", "type": "int"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(MessageCountDetails, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.active_message_count = None self.dead_letter_message_count = None self.scheduled_message_count = None @@ -809,7 +767,7 @@ def __init__( self.transfer_dead_letter_message_count = None -class MigrationConfigListResult(msrest.serialization.Model): +class MigrationConfigListResult(_serialization.Model): """The result of the List migrationConfigurations operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -823,26 +781,21 @@ class MigrationConfigListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[MigrationConfigProperties]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[MigrationConfigProperties]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["_models.MigrationConfigProperties"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.MigrationConfigProperties"]] = None, **kwargs): """ :keyword value: List of Migration Configs. :paramtype value: list[~azure.mgmt.servicebus.v2021_06_01_preview.models.MigrationConfigProperties] """ - super(MigrationConfigListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None @@ -863,7 +816,7 @@ class MigrationConfigProperties(Resource): :ivar provisioning_state: Provisioning state of Migration Configuration. :vartype provisioning_state: str :ivar pending_replication_operations_count: Number of entities pending to be replicated. - :vartype pending_replication_operations_count: long + :vartype pending_replication_operations_count: int :ivar target_namespace: Existing premium Namespace ARM Id name which has no entities, will be used for migration. :vartype target_namespace: str @@ -875,34 +828,28 @@ class MigrationConfigProperties(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'pending_replication_operations_count': {'readonly': True}, - 'migration_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "pending_replication_operations_count": {"readonly": True}, + "migration_state": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'pending_replication_operations_count': {'key': 'properties.pendingReplicationOperationsCount', 'type': 'long'}, - 'target_namespace': {'key': 'properties.targetNamespace', 'type': 'str'}, - 'post_migration_name': {'key': 'properties.postMigrationName', 'type': 'str'}, - 'migration_state': {'key': 'properties.migrationState', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "pending_replication_operations_count": {"key": "properties.pendingReplicationOperationsCount", "type": "int"}, + "target_namespace": {"key": "properties.targetNamespace", "type": "str"}, + "post_migration_name": {"key": "properties.postMigrationName", "type": "str"}, + "migration_state": {"key": "properties.migrationState", "type": "str"}, } - def __init__( - self, - *, - target_namespace: Optional[str] = None, - post_migration_name: Optional[str] = None, - **kwargs - ): + def __init__(self, *, target_namespace: Optional[str] = None, post_migration_name: Optional[str] = None, **kwargs): """ :keyword target_namespace: Existing premium Namespace ARM Id name which has no entities, will be used for migration. @@ -910,7 +857,7 @@ def __init__( :keyword post_migration_name: Name to access Standard Namespace after migration. :paramtype post_migration_name: str """ - super(MigrationConfigProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.provisioning_state = None self.pending_replication_operations_count = None @@ -935,7 +882,8 @@ class NetworkRuleSet(Resource): :ivar trusted_service_access_enabled: Value that indicates whether Trusted Service Access is Enabled or not. :vartype trusted_service_access_enabled: bool - :ivar default_action: Default Action for Network Rule Set. Known values are: "Allow", "Deny". + :ivar default_action: Default Action for Network Rule Set. Known values are: "Allow" and + "Deny". :vartype default_action: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.DefaultAction :ivar virtual_network_rules: List VirtualNetwork Rules. :vartype virtual_network_rules: @@ -943,28 +891,28 @@ class NetworkRuleSet(Resource): :ivar ip_rules: List of IpRules. :vartype ip_rules: list[~azure.mgmt.servicebus.v2021_06_01_preview.models.NWRuleSetIpRules] :ivar public_network_access: This determines if traffic is allowed over public network. By - default it is enabled. Known values are: "Enabled", "Disabled". Default value: "Enabled". + default it is enabled. Known values are: "Enabled" and "Disabled". :vartype public_network_access: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.PublicNetworkAccessFlag """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'trusted_service_access_enabled': {'key': 'properties.trustedServiceAccessEnabled', 'type': 'bool'}, - 'default_action': {'key': 'properties.defaultAction', 'type': 'str'}, - 'virtual_network_rules': {'key': 'properties.virtualNetworkRules', 'type': '[NWRuleSetVirtualNetworkRules]'}, - 'ip_rules': {'key': 'properties.ipRules', 'type': '[NWRuleSetIpRules]'}, - 'public_network_access': {'key': 'properties.publicNetworkAccess', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "trusted_service_access_enabled": {"key": "properties.trustedServiceAccessEnabled", "type": "bool"}, + "default_action": {"key": "properties.defaultAction", "type": "str"}, + "virtual_network_rules": {"key": "properties.virtualNetworkRules", "type": "[NWRuleSetVirtualNetworkRules]"}, + "ip_rules": {"key": "properties.ipRules", "type": "[NWRuleSetIpRules]"}, + "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, } def __init__( @@ -974,14 +922,14 @@ def __init__( default_action: Optional[Union[str, "_models.DefaultAction"]] = None, virtual_network_rules: Optional[List["_models.NWRuleSetVirtualNetworkRules"]] = None, ip_rules: Optional[List["_models.NWRuleSetIpRules"]] = None, - public_network_access: Optional[Union[str, "_models.PublicNetworkAccessFlag"]] = "Enabled", + public_network_access: Union[str, "_models.PublicNetworkAccessFlag"] = "Enabled", **kwargs ): """ :keyword trusted_service_access_enabled: Value that indicates whether Trusted Service Access is Enabled or not. :paramtype trusted_service_access_enabled: bool - :keyword default_action: Default Action for Network Rule Set. Known values are: "Allow", + :keyword default_action: Default Action for Network Rule Set. Known values are: "Allow" and "Deny". :paramtype default_action: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.DefaultAction @@ -991,11 +939,11 @@ def __init__( :keyword ip_rules: List of IpRules. :paramtype ip_rules: list[~azure.mgmt.servicebus.v2021_06_01_preview.models.NWRuleSetIpRules] :keyword public_network_access: This determines if traffic is allowed over public network. By - default it is enabled. Known values are: "Enabled", "Disabled". Default value: "Enabled". + default it is enabled. Known values are: "Enabled" and "Disabled". :paramtype public_network_access: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.PublicNetworkAccessFlag """ - super(NetworkRuleSet, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.trusted_service_access_enabled = trusted_service_access_enabled self.default_action = default_action @@ -1004,7 +952,7 @@ def __init__( self.public_network_access = public_network_access -class NetworkRuleSetListResult(msrest.serialization.Model): +class NetworkRuleSetListResult(_serialization.Model): """The response of the List NetworkRuleSet operation. :ivar value: Result of the List NetworkRuleSet operation. @@ -1015,16 +963,12 @@ class NetworkRuleSetListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[NetworkRuleSet]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[NetworkRuleSet]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["_models.NetworkRuleSet"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.NetworkRuleSet"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Result of the List NetworkRuleSet operation. @@ -1033,44 +977,40 @@ def __init__( list of NetworkRuleSet. :paramtype next_link: str """ - super(NetworkRuleSetListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class NWRuleSetIpRules(msrest.serialization.Model): +class NWRuleSetIpRules(_serialization.Model): """Description of NetWorkRuleSet - IpRules resource. :ivar ip_mask: IP Mask. :vartype ip_mask: str - :ivar action: The IP Filter Action. Known values are: "Allow". Default value: "Allow". + :ivar action: The IP Filter Action. "Allow" :vartype action: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.NetworkRuleIPAction """ _attribute_map = { - 'ip_mask': {'key': 'ipMask', 'type': 'str'}, - 'action': {'key': 'action', 'type': 'str'}, + "ip_mask": {"key": "ipMask", "type": "str"}, + "action": {"key": "action", "type": "str"}, } def __init__( - self, - *, - ip_mask: Optional[str] = None, - action: Optional[Union[str, "_models.NetworkRuleIPAction"]] = "Allow", - **kwargs + self, *, ip_mask: Optional[str] = None, action: Union[str, "_models.NetworkRuleIPAction"] = "Allow", **kwargs ): """ :keyword ip_mask: IP Mask. :paramtype ip_mask: str - :keyword action: The IP Filter Action. Known values are: "Allow". Default value: "Allow". + :keyword action: The IP Filter Action. "Allow" :paramtype action: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.NetworkRuleIPAction """ - super(NWRuleSetIpRules, self).__init__(**kwargs) + super().__init__(**kwargs) self.ip_mask = ip_mask self.action = action -class NWRuleSetVirtualNetworkRules(msrest.serialization.Model): +class NWRuleSetVirtualNetworkRules(_serialization.Model): """Description of VirtualNetworkRules - NetworkRules resource. :ivar subnet: Subnet properties. @@ -1081,8 +1021,8 @@ class NWRuleSetVirtualNetworkRules(msrest.serialization.Model): """ _attribute_map = { - 'subnet': {'key': 'subnet', 'type': 'Subnet'}, - 'ignore_missing_vnet_service_endpoint': {'key': 'ignoreMissingVnetServiceEndpoint', 'type': 'bool'}, + "subnet": {"key": "subnet", "type": "Subnet"}, + "ignore_missing_vnet_service_endpoint": {"key": "ignoreMissingVnetServiceEndpoint", "type": "bool"}, } def __init__( @@ -1099,12 +1039,12 @@ def __init__( VNet Service Endpoint. :paramtype ignore_missing_vnet_service_endpoint: bool """ - super(NWRuleSetVirtualNetworkRules, self).__init__(**kwargs) + super().__init__(**kwargs) self.subnet = subnet self.ignore_missing_vnet_service_endpoint = ignore_missing_vnet_service_endpoint -class Operation(msrest.serialization.Model): +class Operation(_serialization.Model): """A ServiceBus REST API operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -1116,30 +1056,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["_models.OperationDisplay"] = None, - **kwargs - ): + def __init__(self, *, display: Optional["_models.OperationDisplay"] = None, **kwargs): """ :keyword display: The object that represents the operation. :paramtype display: ~azure.mgmt.servicebus.v2021_06_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. @@ -1153,30 +1088,26 @@ 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 OperationListResult(msrest.serialization.Model): +class OperationListResult(_serialization.Model): """Result of the request to list ServiceBus 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. @@ -1189,27 +1120,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): """PrivateEndpoint information. :ivar id: The ARM identifier for Private Endpoint. @@ -1217,20 +1144,15 @@ class PrivateEndpoint(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - *, - id: Optional[str] = None, - **kwargs - ): + def __init__(self, *, id: Optional[str] = None, **kwargs): # pylint: disable=redefined-builtin """ :keyword id: The ARM identifier for Private Endpoint. :paramtype id: str """ - super(PrivateEndpoint, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id @@ -1253,26 +1175,29 @@ class PrivateEndpointConnection(Resource): :vartype private_link_service_connection_state: ~azure.mgmt.servicebus.v2021_06_01_preview.models.ConnectionState :ivar provisioning_state: Provisioning state of the Private Endpoint Connection. Known values - are: "Creating", "Updating", "Deleting", "Succeeded", "Canceled", "Failed". + are: "Creating", "Updating", "Deleting", "Succeeded", "Canceled", and "Failed". :vartype provisioning_state: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.EndPointProvisioningState """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'private_endpoint': {'key': 'properties.privateEndpoint', 'type': 'PrivateEndpoint'}, - 'private_link_service_connection_state': {'key': 'properties.privateLinkServiceConnectionState', 'type': 'ConnectionState'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "private_endpoint": {"key": "properties.privateEndpoint", "type": "PrivateEndpoint"}, + "private_link_service_connection_state": { + "key": "properties.privateLinkServiceConnectionState", + "type": "ConnectionState", + }, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, } def __init__( @@ -1290,18 +1215,18 @@ def __init__( :paramtype private_link_service_connection_state: ~azure.mgmt.servicebus.v2021_06_01_preview.models.ConnectionState :keyword provisioning_state: Provisioning state of the Private Endpoint Connection. Known - values are: "Creating", "Updating", "Deleting", "Succeeded", "Canceled", "Failed". + values are: "Creating", "Updating", "Deleting", "Succeeded", "Canceled", and "Failed". :paramtype provisioning_state: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.EndPointProvisioningState """ - super(PrivateEndpointConnection, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.private_endpoint = private_endpoint self.private_link_service_connection_state = private_link_service_connection_state self.provisioning_state = provisioning_state -class PrivateEndpointConnectionListResult(msrest.serialization.Model): +class PrivateEndpointConnectionListResult(_serialization.Model): """Result of the list of all private endpoint connections operation. :ivar value: A collection of private endpoint connection resources. @@ -1312,8 +1237,8 @@ class PrivateEndpointConnectionListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PrivateEndpointConnection]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[PrivateEndpointConnection]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( @@ -1330,12 +1255,12 @@ def __init__( :keyword next_link: A link for the next page of private endpoint connection resources. :paramtype next_link: str """ - super(PrivateEndpointConnectionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class PrivateLinkResource(msrest.serialization.Model): +class PrivateLinkResource(_serialization.Model): """Information of the private link resource. :ivar id: Fully qualified identifier of the resource. @@ -1353,18 +1278,18 @@ class PrivateLinkResource(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'group_id': {'key': 'properties.groupId', 'type': 'str'}, - 'required_members': {'key': 'properties.requiredMembers', 'type': '[str]'}, - 'required_zone_names': {'key': 'properties.requiredZoneNames', 'type': '[str]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "group_id": {"key": "properties.groupId", "type": "str"}, + "required_members": {"key": "properties.requiredMembers", "type": "[str]"}, + "required_zone_names": {"key": "properties.requiredZoneNames", "type": "[str]"}, } def __init__( self, *, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin name: Optional[str] = None, type: Optional[str] = None, group_id: Optional[str] = None, @@ -1386,7 +1311,7 @@ def __init__( :keyword required_zone_names: Required Zone Names. :paramtype required_zone_names: list[str] """ - super(PrivateLinkResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.name = name self.type = type @@ -1395,7 +1320,7 @@ def __init__( self.required_zone_names = required_zone_names -class PrivateLinkResourcesListResult(msrest.serialization.Model): +class PrivateLinkResourcesListResult(_serialization.Model): """Result of the List private link resources operation. :ivar value: A collection of private link resources. @@ -1405,16 +1330,12 @@ class PrivateLinkResourcesListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PrivateLinkResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[PrivateLinkResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["_models.PrivateLinkResource"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.PrivateLinkResource"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: A collection of private link resources. @@ -1422,17 +1343,17 @@ def __init__( :keyword next_link: A link for the next page of private link resources. :paramtype next_link: str """ - super(PrivateLinkResourcesListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class RegenerateAccessKeyParameters(msrest.serialization.Model): +class RegenerateAccessKeyParameters(_serialization.Model): """Parameters supplied to the Regenerate Authorization Rule operation, specifies which key needs to be reset. All required parameters must be populated in order to send to Azure. - :ivar key_type: Required. The access key to regenerate. Known values are: "PrimaryKey", + :ivar key_type: The access key to regenerate. Required. Known values are: "PrimaryKey" and "SecondaryKey". :vartype key_type: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.KeyType :ivar key: Optional, if the key value provided, is reset for KeyType value or autogenerate Key @@ -1441,30 +1362,24 @@ class RegenerateAccessKeyParameters(msrest.serialization.Model): """ _validation = { - 'key_type': {'required': True}, + "key_type": {"required": True}, } _attribute_map = { - 'key_type': {'key': 'keyType', 'type': 'str'}, - 'key': {'key': 'key', 'type': 'str'}, + "key_type": {"key": "keyType", "type": "str"}, + "key": {"key": "key", "type": "str"}, } - def __init__( - self, - *, - key_type: Union[str, "_models.KeyType"], - key: Optional[str] = None, - **kwargs - ): + def __init__(self, *, key_type: Union[str, "_models.KeyType"], key: Optional[str] = None, **kwargs): """ - :keyword key_type: Required. The access key to regenerate. Known values are: "PrimaryKey", + :keyword key_type: The access key to regenerate. Required. Known values are: "PrimaryKey" and "SecondaryKey". :paramtype key_type: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.KeyType :keyword key: Optional, if the key value provided, is reset for KeyType value or autogenerate Key value set for keyType. :paramtype key: str """ - super(RegenerateAccessKeyParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_type = key_type self.key = key @@ -1482,38 +1397,32 @@ class ResourceNamespacePatch(Resource): :vartype type: str :ivar location: Resource location. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"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}'}, + "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: Optional[str] = None, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, **kwargs): """ :keyword location: Resource location. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] """ - super(ResourceNamespacePatch, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.tags = tags @@ -1535,7 +1444,7 @@ class Rule(Resource): message that have been matched by a filter expression. :vartype action: ~azure.mgmt.servicebus.v2021_06_01_preview.models.Action :ivar filter_type: Filter type that is evaluated against a BrokeredMessage. Known values are: - "SqlFilter", "CorrelationFilter". + "SqlFilter" and "CorrelationFilter". :vartype filter_type: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.FilterType :ivar sql_filter: Properties of sqlFilter. :vartype sql_filter: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SqlFilter @@ -1545,21 +1454,21 @@ class Rule(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'action': {'key': 'properties.action', 'type': 'Action'}, - 'filter_type': {'key': 'properties.filterType', 'type': 'str'}, - 'sql_filter': {'key': 'properties.sqlFilter', 'type': 'SqlFilter'}, - 'correlation_filter': {'key': 'properties.correlationFilter', 'type': 'CorrelationFilter'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "action": {"key": "properties.action", "type": "Action"}, + "filter_type": {"key": "properties.filterType", "type": "str"}, + "sql_filter": {"key": "properties.sqlFilter", "type": "SqlFilter"}, + "correlation_filter": {"key": "properties.correlationFilter", "type": "CorrelationFilter"}, } def __init__( @@ -1576,7 +1485,7 @@ def __init__( message that have been matched by a filter expression. :paramtype action: ~azure.mgmt.servicebus.v2021_06_01_preview.models.Action :keyword filter_type: Filter type that is evaluated against a BrokeredMessage. Known values - are: "SqlFilter", "CorrelationFilter". + are: "SqlFilter" and "CorrelationFilter". :paramtype filter_type: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.FilterType :keyword sql_filter: Properties of sqlFilter. :paramtype sql_filter: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SqlFilter @@ -1584,7 +1493,7 @@ def __init__( :paramtype correlation_filter: ~azure.mgmt.servicebus.v2021_06_01_preview.models.CorrelationFilter """ - super(Rule, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.action = action self.filter_type = filter_type @@ -1592,7 +1501,7 @@ def __init__( self.correlation_filter = correlation_filter -class RuleListResult(msrest.serialization.Model): +class RuleListResult(_serialization.Model): """The response of the List rule operation. :ivar value: Result of the List Rules operation. @@ -1603,17 +1512,11 @@ class RuleListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Rule]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Rule]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["_models.Rule"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Rule"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: Result of the List Rules operation. :paramtype value: list[~azure.mgmt.servicebus.v2021_06_01_preview.models.Rule] @@ -1621,7 +1524,7 @@ def __init__( list of rules. :paramtype next_link: str """ - super(RuleListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link @@ -1644,36 +1547,31 @@ class SBAuthorizationRule(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'rights': {'key': 'properties.rights', 'type': '[str]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "rights": {"key": "properties.rights", "type": "[str]"}, } - def __init__( - self, - *, - rights: Optional[List[Union[str, "_models.AccessRights"]]] = None, - **kwargs - ): + def __init__(self, *, rights: Optional[List[Union[str, "_models.AccessRights"]]] = None, **kwargs): """ :keyword rights: The rights associated with the rule. :paramtype rights: list[str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.AccessRights] """ - super(SBAuthorizationRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.rights = rights -class SBAuthorizationRuleListResult(msrest.serialization.Model): +class SBAuthorizationRuleListResult(_serialization.Model): """The response to the List Namespace operation. :ivar value: Result of the List Authorization Rules operation. @@ -1684,16 +1582,12 @@ class SBAuthorizationRuleListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[SBAuthorizationRule]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SBAuthorizationRule]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["_models.SBAuthorizationRule"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.SBAuthorizationRule"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Result of the List Authorization Rules operation. @@ -1702,12 +1596,12 @@ def __init__( list of Authorization Rules. :paramtype next_link: str """ - super(SBAuthorizationRuleListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class SBClientAffineProperties(msrest.serialization.Model): +class SBClientAffineProperties(_serialization.Model): """Properties specific to client affine subscriptions. :ivar client_id: Indicates the Client ID of the application that created the client-affine @@ -1722,9 +1616,9 @@ class SBClientAffineProperties(msrest.serialization.Model): """ _attribute_map = { - 'client_id': {'key': 'clientId', 'type': 'str'}, - 'is_durable': {'key': 'isDurable', 'type': 'bool'}, - 'is_shared': {'key': 'isShared', 'type': 'bool'}, + "client_id": {"key": "clientId", "type": "str"}, + "is_durable": {"key": "isDurable", "type": "bool"}, + "is_shared": {"key": "isShared", "type": "bool"}, } def __init__( @@ -1746,7 +1640,7 @@ def __init__( subscription is shared or not. :paramtype is_shared: bool """ - super(SBClientAffineProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.client_id = client_id self.is_durable = is_durable self.is_shared = is_shared @@ -1765,46 +1659,40 @@ class TrackedResource(Resource): :vartype name: str :ivar type: Resource type. :vartype type: str - :ivar location: Required. The Geo-location where the resource lives. + :ivar location: The Geo-location where the resource lives. Required. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "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 Geo-location where the resource lives. + :keyword location: The Geo-location where the resource lives. Required. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] """ - super(TrackedResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.tags = tags -class SBNamespace(TrackedResource): +class SBNamespace(TrackedResource): # pylint: disable=too-many-instance-attributes """Description of a namespace resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -1817,9 +1705,9 @@ class SBNamespace(TrackedResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :ivar location: Required. The Geo-location where the resource lives. + :ivar location: The Geo-location where the resource lives. Required. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar sku: Properties of SKU. :vartype sku: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBSku @@ -1853,38 +1741,41 @@ class SBNamespace(TrackedResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'status': {'readonly': True}, - 'created_at': {'readonly': True}, - 'updated_at': {'readonly': True}, - 'service_bus_endpoint': {'readonly': True}, - 'metric_id': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "system_data": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "status": {"readonly": True}, + "created_at": {"readonly": True}, + "updated_at": {"readonly": True}, + "service_bus_endpoint": {"readonly": True}, + "metric_id": {"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}'}, - 'sku': {'key': 'sku', 'type': 'SBSku'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'created_at': {'key': 'properties.createdAt', 'type': 'iso-8601'}, - 'updated_at': {'key': 'properties.updatedAt', 'type': 'iso-8601'}, - 'service_bus_endpoint': {'key': 'properties.serviceBusEndpoint', 'type': 'str'}, - 'metric_id': {'key': 'properties.metricId', 'type': 'str'}, - 'zone_redundant': {'key': 'properties.zoneRedundant', 'type': 'bool'}, - 'encryption': {'key': 'properties.encryption', 'type': 'Encryption'}, - 'private_endpoint_connections': {'key': 'properties.privateEndpointConnections', 'type': '[PrivateEndpointConnection]'}, - 'disable_local_auth': {'key': 'properties.disableLocalAuth', 'type': 'bool'}, + "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}"}, + "sku": {"key": "sku", "type": "SBSku"}, + "identity": {"key": "identity", "type": "Identity"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "status": {"key": "properties.status", "type": "str"}, + "created_at": {"key": "properties.createdAt", "type": "iso-8601"}, + "updated_at": {"key": "properties.updatedAt", "type": "iso-8601"}, + "service_bus_endpoint": {"key": "properties.serviceBusEndpoint", "type": "str"}, + "metric_id": {"key": "properties.metricId", "type": "str"}, + "zone_redundant": {"key": "properties.zoneRedundant", "type": "bool"}, + "encryption": {"key": "properties.encryption", "type": "Encryption"}, + "private_endpoint_connections": { + "key": "properties.privateEndpointConnections", + "type": "[PrivateEndpointConnection]", + }, + "disable_local_auth": {"key": "properties.disableLocalAuth", "type": "bool"}, } def __init__( @@ -1901,9 +1792,9 @@ def __init__( **kwargs ): """ - :keyword location: Required. The Geo-location where the resource lives. + :keyword location: The Geo-location where the resource lives. Required. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword sku: Properties of SKU. :paramtype sku: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBSku @@ -1921,7 +1812,7 @@ def __init__( namespace. :paramtype disable_local_auth: bool """ - super(SBNamespace, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.sku = sku self.identity = identity self.system_data = None @@ -1937,7 +1828,7 @@ def __init__( self.disable_local_auth = disable_local_auth -class SBNamespaceListResult(msrest.serialization.Model): +class SBNamespaceListResult(_serialization.Model): """The response of the List Namespace operation. :ivar value: Result of the List Namespace operation. @@ -1948,16 +1839,12 @@ class SBNamespaceListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[SBNamespace]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SBNamespace]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["_models.SBNamespace"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.SBNamespace"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Result of the List Namespace operation. @@ -1966,12 +1853,12 @@ def __init__( list of Namespaces. :paramtype next_link: str """ - super(SBNamespaceListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class SBNamespaceUpdateParameters(ResourceNamespacePatch): +class SBNamespaceUpdateParameters(ResourceNamespacePatch): # pylint: disable=too-many-instance-attributes """Description of a namespace resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -1984,7 +1871,7 @@ class SBNamespaceUpdateParameters(ResourceNamespacePatch): :vartype type: str :ivar location: Resource location. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar sku: Properties of SKU. :vartype sku: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBSku @@ -2016,35 +1903,38 @@ class SBNamespaceUpdateParameters(ResourceNamespacePatch): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'status': {'readonly': True}, - 'created_at': {'readonly': True}, - 'updated_at': {'readonly': True}, - 'service_bus_endpoint': {'readonly': True}, - 'metric_id': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "status": {"readonly": True}, + "created_at": {"readonly": True}, + "updated_at": {"readonly": True}, + "service_bus_endpoint": {"readonly": True}, + "metric_id": {"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}'}, - 'sku': {'key': 'sku', 'type': 'SBSku'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'created_at': {'key': 'properties.createdAt', 'type': 'iso-8601'}, - 'updated_at': {'key': 'properties.updatedAt', 'type': 'iso-8601'}, - 'service_bus_endpoint': {'key': 'properties.serviceBusEndpoint', 'type': 'str'}, - 'metric_id': {'key': 'properties.metricId', 'type': 'str'}, - 'zone_redundant': {'key': 'properties.zoneRedundant', 'type': 'bool'}, - 'encryption': {'key': 'properties.encryption', 'type': 'Encryption'}, - 'private_endpoint_connections': {'key': 'properties.privateEndpointConnections', 'type': '[PrivateEndpointConnection]'}, - 'disable_local_auth': {'key': 'properties.disableLocalAuth', 'type': 'bool'}, + "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}"}, + "sku": {"key": "sku", "type": "SBSku"}, + "identity": {"key": "identity", "type": "Identity"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "status": {"key": "properties.status", "type": "str"}, + "created_at": {"key": "properties.createdAt", "type": "iso-8601"}, + "updated_at": {"key": "properties.updatedAt", "type": "iso-8601"}, + "service_bus_endpoint": {"key": "properties.serviceBusEndpoint", "type": "str"}, + "metric_id": {"key": "properties.metricId", "type": "str"}, + "zone_redundant": {"key": "properties.zoneRedundant", "type": "bool"}, + "encryption": {"key": "properties.encryption", "type": "Encryption"}, + "private_endpoint_connections": { + "key": "properties.privateEndpointConnections", + "type": "[PrivateEndpointConnection]", + }, + "disable_local_auth": {"key": "properties.disableLocalAuth", "type": "bool"}, } def __init__( @@ -2063,7 +1953,7 @@ def __init__( """ :keyword location: Resource location. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword sku: Properties of SKU. :paramtype sku: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBSku @@ -2081,7 +1971,7 @@ def __init__( namespace. :paramtype disable_local_auth: bool """ - super(SBNamespaceUpdateParameters, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.sku = sku self.identity = identity self.provisioning_state = None @@ -2096,7 +1986,7 @@ def __init__( self.disable_local_auth = disable_local_auth -class SBQueue(Resource): +class SBQueue(Resource): # pylint: disable=too-many-instance-attributes """Description of queue Resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -2119,9 +2009,9 @@ class SBQueue(Resource): to this queue. :vartype accessed_at: ~datetime.datetime :ivar size_in_bytes: The size of the queue, in bytes. - :vartype size_in_bytes: long + :vartype size_in_bytes: int :ivar message_count: The number of messages in the queue. - :vartype message_count: long + :vartype message_count: int :ivar lock_duration: ISO 8601 timespan duration of a peek-lock; that is, the amount of time that the message is locked for other receivers. The maximum value for LockDuration is 5 minutes; the default value is 1 minute. @@ -2131,7 +2021,7 @@ class SBQueue(Resource): :vartype max_size_in_megabytes: int :ivar max_message_size_in_kilobytes: Maximum size (in KB) of the message payload that can be accepted by the queue. This property is only used in Premium today and default is 1024. - :vartype max_message_size_in_kilobytes: long + :vartype max_message_size_in_kilobytes: int :ivar requires_duplicate_detection: A value indicating if this queue requires duplicate detection. :vartype requires_duplicate_detection: bool @@ -2153,7 +2043,7 @@ class SBQueue(Resource): :vartype max_delivery_count: int :ivar status: Enumerates the possible values for the status of a messaging entity. Known values are: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", "Creating", - "Deleting", "Renaming", "Unknown". + "Deleting", "Renaming", and "Unknown". :vartype status: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.EntityStatus :ivar enable_batched_operations: Value that indicates whether server-side batched operations are enabled. @@ -2174,48 +2064,51 @@ class SBQueue(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'count_details': {'readonly': True}, - 'created_at': {'readonly': True}, - 'updated_at': {'readonly': True}, - 'accessed_at': {'readonly': True}, - 'size_in_bytes': {'readonly': True}, - 'message_count': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "count_details": {"readonly": True}, + "created_at": {"readonly": True}, + "updated_at": {"readonly": True}, + "accessed_at": {"readonly": True}, + "size_in_bytes": {"readonly": True}, + "message_count": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'count_details': {'key': 'properties.countDetails', 'type': 'MessageCountDetails'}, - 'created_at': {'key': 'properties.createdAt', 'type': 'iso-8601'}, - 'updated_at': {'key': 'properties.updatedAt', 'type': 'iso-8601'}, - 'accessed_at': {'key': 'properties.accessedAt', 'type': 'iso-8601'}, - 'size_in_bytes': {'key': 'properties.sizeInBytes', 'type': 'long'}, - 'message_count': {'key': 'properties.messageCount', 'type': 'long'}, - 'lock_duration': {'key': 'properties.lockDuration', 'type': 'duration'}, - 'max_size_in_megabytes': {'key': 'properties.maxSizeInMegabytes', 'type': 'int'}, - 'max_message_size_in_kilobytes': {'key': 'properties.maxMessageSizeInKilobytes', 'type': 'long'}, - 'requires_duplicate_detection': {'key': 'properties.requiresDuplicateDetection', 'type': 'bool'}, - 'requires_session': {'key': 'properties.requiresSession', 'type': 'bool'}, - 'default_message_time_to_live': {'key': 'properties.defaultMessageTimeToLive', 'type': 'duration'}, - 'dead_lettering_on_message_expiration': {'key': 'properties.deadLetteringOnMessageExpiration', 'type': 'bool'}, - 'duplicate_detection_history_time_window': {'key': 'properties.duplicateDetectionHistoryTimeWindow', 'type': 'duration'}, - 'max_delivery_count': {'key': 'properties.maxDeliveryCount', 'type': 'int'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'enable_batched_operations': {'key': 'properties.enableBatchedOperations', 'type': 'bool'}, - 'auto_delete_on_idle': {'key': 'properties.autoDeleteOnIdle', 'type': 'duration'}, - 'enable_partitioning': {'key': 'properties.enablePartitioning', 'type': 'bool'}, - 'enable_express': {'key': 'properties.enableExpress', 'type': 'bool'}, - 'forward_to': {'key': 'properties.forwardTo', 'type': 'str'}, - 'forward_dead_lettered_messages_to': {'key': 'properties.forwardDeadLetteredMessagesTo', 'type': 'str'}, - } - - def __init__( + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "count_details": {"key": "properties.countDetails", "type": "MessageCountDetails"}, + "created_at": {"key": "properties.createdAt", "type": "iso-8601"}, + "updated_at": {"key": "properties.updatedAt", "type": "iso-8601"}, + "accessed_at": {"key": "properties.accessedAt", "type": "iso-8601"}, + "size_in_bytes": {"key": "properties.sizeInBytes", "type": "int"}, + "message_count": {"key": "properties.messageCount", "type": "int"}, + "lock_duration": {"key": "properties.lockDuration", "type": "duration"}, + "max_size_in_megabytes": {"key": "properties.maxSizeInMegabytes", "type": "int"}, + "max_message_size_in_kilobytes": {"key": "properties.maxMessageSizeInKilobytes", "type": "int"}, + "requires_duplicate_detection": {"key": "properties.requiresDuplicateDetection", "type": "bool"}, + "requires_session": {"key": "properties.requiresSession", "type": "bool"}, + "default_message_time_to_live": {"key": "properties.defaultMessageTimeToLive", "type": "duration"}, + "dead_lettering_on_message_expiration": {"key": "properties.deadLetteringOnMessageExpiration", "type": "bool"}, + "duplicate_detection_history_time_window": { + "key": "properties.duplicateDetectionHistoryTimeWindow", + "type": "duration", + }, + "max_delivery_count": {"key": "properties.maxDeliveryCount", "type": "int"}, + "status": {"key": "properties.status", "type": "str"}, + "enable_batched_operations": {"key": "properties.enableBatchedOperations", "type": "bool"}, + "auto_delete_on_idle": {"key": "properties.autoDeleteOnIdle", "type": "duration"}, + "enable_partitioning": {"key": "properties.enablePartitioning", "type": "bool"}, + "enable_express": {"key": "properties.enableExpress", "type": "bool"}, + "forward_to": {"key": "properties.forwardTo", "type": "str"}, + "forward_dead_lettered_messages_to": {"key": "properties.forwardDeadLetteredMessagesTo", "type": "str"}, + } + + def __init__( # pylint: disable=too-many-locals self, *, lock_duration: Optional[datetime.timedelta] = None, @@ -2246,7 +2139,7 @@ def __init__( :paramtype max_size_in_megabytes: int :keyword max_message_size_in_kilobytes: Maximum size (in KB) of the message payload that can be accepted by the queue. This property is only used in Premium today and default is 1024. - :paramtype max_message_size_in_kilobytes: long + :paramtype max_message_size_in_kilobytes: int :keyword requires_duplicate_detection: A value indicating if this queue requires duplicate detection. :paramtype requires_duplicate_detection: bool @@ -2268,7 +2161,7 @@ def __init__( :paramtype max_delivery_count: int :keyword status: Enumerates the possible values for the status of a messaging entity. Known values are: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", "Creating", - "Deleting", "Renaming", "Unknown". + "Deleting", "Renaming", and "Unknown". :paramtype status: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.EntityStatus :keyword enable_batched_operations: Value that indicates whether server-side batched operations are enabled. @@ -2288,7 +2181,7 @@ def __init__( message. :paramtype forward_dead_lettered_messages_to: str """ - super(SBQueue, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.count_details = None self.created_at = None @@ -2314,7 +2207,7 @@ def __init__( self.forward_dead_lettered_messages_to = forward_dead_lettered_messages_to -class SBQueueListResult(msrest.serialization.Model): +class SBQueueListResult(_serialization.Model): """The response to the List Queues operation. :ivar value: Result of the List Queues operation. @@ -2325,17 +2218,11 @@ class SBQueueListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[SBQueue]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SBQueue]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["_models.SBQueue"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.SBQueue"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: Result of the List Queues operation. :paramtype value: list[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBQueue] @@ -2343,19 +2230,19 @@ def __init__( list of queues. :paramtype next_link: str """ - super(SBQueueListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class SBSku(msrest.serialization.Model): +class SBSku(_serialization.Model): """SKU of the namespace. All required parameters must be populated in order to send to Azure. - :ivar name: Required. Name of this SKU. Known values are: "Basic", "Standard", "Premium". + :ivar name: Name of this SKU. Required. Known values are: "Basic", "Standard", and "Premium". :vartype name: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.SkuName - :ivar tier: The billing tier of this particular SKU. Known values are: "Basic", "Standard", + :ivar tier: The billing tier of this particular SKU. Known values are: "Basic", "Standard", and "Premium". :vartype tier: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.SkuTier :ivar capacity: The specified messaging units for the tier. For Premium tier, capacity are 1,2 @@ -2364,13 +2251,13 @@ class SBSku(msrest.serialization.Model): """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'capacity': {'key': 'capacity', 'type': 'int'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "capacity": {"key": "capacity", "type": "int"}, } def __init__( @@ -2382,22 +2269,23 @@ def __init__( **kwargs ): """ - :keyword name: Required. Name of this SKU. Known values are: "Basic", "Standard", "Premium". + :keyword name: Name of this SKU. Required. Known values are: "Basic", "Standard", and + "Premium". :paramtype name: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.SkuName :keyword tier: The billing tier of this particular SKU. Known values are: "Basic", "Standard", - "Premium". + and "Premium". :paramtype tier: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.SkuTier :keyword capacity: The specified messaging units for the tier. For Premium tier, capacity are 1,2 and 4. :paramtype capacity: int """ - super(SBSku, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.tier = tier self.capacity = capacity -class SBSubscription(Resource): +class SBSubscription(Resource): # pylint: disable=too-many-instance-attributes """Description of subscription resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -2411,7 +2299,7 @@ class SBSubscription(Resource): :ivar system_data: The system meta data relating to this resource. :vartype system_data: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SystemData :ivar message_count: Number of messages. - :vartype message_count: long + :vartype message_count: int :ivar created_at: Exact time the message was created. :vartype created_at: ~datetime.datetime :ivar accessed_at: Last time there was a receive request to this subscription. @@ -2442,7 +2330,7 @@ class SBSubscription(Resource): :vartype max_delivery_count: int :ivar status: Enumerates the possible values for the status of a messaging entity. Known values are: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", "Creating", - "Deleting", "Renaming", "Unknown". + "Deleting", "Renaming", and "Unknown". :vartype status: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.EntityStatus :ivar enable_batched_operations: Value that indicates whether server-side batched operations are enabled. @@ -2463,41 +2351,47 @@ class SBSubscription(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'message_count': {'readonly': True}, - 'created_at': {'readonly': True}, - 'accessed_at': {'readonly': True}, - 'updated_at': {'readonly': True}, - 'count_details': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "message_count": {"readonly": True}, + "created_at": {"readonly": True}, + "accessed_at": {"readonly": True}, + "updated_at": {"readonly": True}, + "count_details": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'message_count': {'key': 'properties.messageCount', 'type': 'long'}, - 'created_at': {'key': 'properties.createdAt', 'type': 'iso-8601'}, - 'accessed_at': {'key': 'properties.accessedAt', 'type': 'iso-8601'}, - 'updated_at': {'key': 'properties.updatedAt', 'type': 'iso-8601'}, - 'count_details': {'key': 'properties.countDetails', 'type': 'MessageCountDetails'}, - 'lock_duration': {'key': 'properties.lockDuration', 'type': 'duration'}, - 'requires_session': {'key': 'properties.requiresSession', 'type': 'bool'}, - 'default_message_time_to_live': {'key': 'properties.defaultMessageTimeToLive', 'type': 'duration'}, - 'dead_lettering_on_filter_evaluation_exceptions': {'key': 'properties.deadLetteringOnFilterEvaluationExceptions', 'type': 'bool'}, - 'dead_lettering_on_message_expiration': {'key': 'properties.deadLetteringOnMessageExpiration', 'type': 'bool'}, - 'duplicate_detection_history_time_window': {'key': 'properties.duplicateDetectionHistoryTimeWindow', 'type': 'duration'}, - 'max_delivery_count': {'key': 'properties.maxDeliveryCount', 'type': 'int'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'enable_batched_operations': {'key': 'properties.enableBatchedOperations', 'type': 'bool'}, - 'auto_delete_on_idle': {'key': 'properties.autoDeleteOnIdle', 'type': 'duration'}, - 'forward_to': {'key': 'properties.forwardTo', 'type': 'str'}, - 'forward_dead_lettered_messages_to': {'key': 'properties.forwardDeadLetteredMessagesTo', 'type': 'str'}, - 'is_client_affine': {'key': 'properties.isClientAffine', 'type': 'bool'}, - 'client_affine_properties': {'key': 'properties.clientAffineProperties', 'type': 'SBClientAffineProperties'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "message_count": {"key": "properties.messageCount", "type": "int"}, + "created_at": {"key": "properties.createdAt", "type": "iso-8601"}, + "accessed_at": {"key": "properties.accessedAt", "type": "iso-8601"}, + "updated_at": {"key": "properties.updatedAt", "type": "iso-8601"}, + "count_details": {"key": "properties.countDetails", "type": "MessageCountDetails"}, + "lock_duration": {"key": "properties.lockDuration", "type": "duration"}, + "requires_session": {"key": "properties.requiresSession", "type": "bool"}, + "default_message_time_to_live": {"key": "properties.defaultMessageTimeToLive", "type": "duration"}, + "dead_lettering_on_filter_evaluation_exceptions": { + "key": "properties.deadLetteringOnFilterEvaluationExceptions", + "type": "bool", + }, + "dead_lettering_on_message_expiration": {"key": "properties.deadLetteringOnMessageExpiration", "type": "bool"}, + "duplicate_detection_history_time_window": { + "key": "properties.duplicateDetectionHistoryTimeWindow", + "type": "duration", + }, + "max_delivery_count": {"key": "properties.maxDeliveryCount", "type": "int"}, + "status": {"key": "properties.status", "type": "str"}, + "enable_batched_operations": {"key": "properties.enableBatchedOperations", "type": "bool"}, + "auto_delete_on_idle": {"key": "properties.autoDeleteOnIdle", "type": "duration"}, + "forward_to": {"key": "properties.forwardTo", "type": "str"}, + "forward_dead_lettered_messages_to": {"key": "properties.forwardDeadLetteredMessagesTo", "type": "str"}, + "is_client_affine": {"key": "properties.isClientAffine", "type": "bool"}, + "client_affine_properties": {"key": "properties.clientAffineProperties", "type": "SBClientAffineProperties"}, } def __init__( @@ -2542,7 +2436,7 @@ def __init__( :paramtype max_delivery_count: int :keyword status: Enumerates the possible values for the status of a messaging entity. Known values are: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", "Creating", - "Deleting", "Renaming", "Unknown". + "Deleting", "Renaming", and "Unknown". :paramtype status: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.EntityStatus :keyword enable_batched_operations: Value that indicates whether server-side batched operations are enabled. @@ -2562,7 +2456,7 @@ def __init__( :paramtype client_affine_properties: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBClientAffineProperties """ - super(SBSubscription, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.message_count = None self.created_at = None @@ -2585,7 +2479,7 @@ def __init__( self.client_affine_properties = client_affine_properties -class SBSubscriptionListResult(msrest.serialization.Model): +class SBSubscriptionListResult(_serialization.Model): """The response to the List Subscriptions operation. :ivar value: Result of the List Subscriptions operation. @@ -2596,16 +2490,12 @@ class SBSubscriptionListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[SBSubscription]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SBSubscription]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["_models.SBSubscription"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.SBSubscription"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Result of the List Subscriptions operation. @@ -2614,12 +2504,12 @@ def __init__( list of subscriptions. :paramtype next_link: str """ - super(SBSubscriptionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class SBTopic(Resource): +class SBTopic(Resource): # pylint: disable=too-many-instance-attributes """Description of topic resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -2633,7 +2523,7 @@ class SBTopic(Resource): :ivar system_data: The system meta data relating to this resource. :vartype system_data: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SystemData :ivar size_in_bytes: Size of the topic, in bytes. - :vartype size_in_bytes: long + :vartype size_in_bytes: int :ivar created_at: Exact time the message was created. :vartype created_at: ~datetime.datetime :ivar updated_at: The exact time the message was updated. @@ -2653,7 +2543,7 @@ class SBTopic(Resource): :vartype max_size_in_megabytes: int :ivar max_message_size_in_kilobytes: Maximum size (in KB) of the message payload that can be accepted by the topic. This property is only used in Premium today and default is 1024. - :vartype max_message_size_in_kilobytes: long + :vartype max_message_size_in_kilobytes: int :ivar requires_duplicate_detection: Value indicating if this topic requires duplicate detection. :vartype requires_duplicate_detection: bool @@ -2665,7 +2555,7 @@ class SBTopic(Resource): :vartype enable_batched_operations: bool :ivar status: Enumerates the possible values for the status of a messaging entity. Known values are: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", "Creating", - "Deleting", "Renaming", "Unknown". + "Deleting", "Renaming", and "Unknown". :vartype status: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.EntityStatus :ivar support_ordering: Value that indicates whether the topic supports ordering. :vartype support_ordering: bool @@ -2681,40 +2571,43 @@ class SBTopic(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'size_in_bytes': {'readonly': True}, - 'created_at': {'readonly': True}, - 'updated_at': {'readonly': True}, - 'accessed_at': {'readonly': True}, - 'subscription_count': {'readonly': True}, - 'count_details': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "size_in_bytes": {"readonly": True}, + "created_at": {"readonly": True}, + "updated_at": {"readonly": True}, + "accessed_at": {"readonly": True}, + "subscription_count": {"readonly": True}, + "count_details": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'size_in_bytes': {'key': 'properties.sizeInBytes', 'type': 'long'}, - 'created_at': {'key': 'properties.createdAt', 'type': 'iso-8601'}, - 'updated_at': {'key': 'properties.updatedAt', 'type': 'iso-8601'}, - 'accessed_at': {'key': 'properties.accessedAt', 'type': 'iso-8601'}, - 'subscription_count': {'key': 'properties.subscriptionCount', 'type': 'int'}, - 'count_details': {'key': 'properties.countDetails', 'type': 'MessageCountDetails'}, - 'default_message_time_to_live': {'key': 'properties.defaultMessageTimeToLive', 'type': 'duration'}, - 'max_size_in_megabytes': {'key': 'properties.maxSizeInMegabytes', 'type': 'int'}, - 'max_message_size_in_kilobytes': {'key': 'properties.maxMessageSizeInKilobytes', 'type': 'long'}, - 'requires_duplicate_detection': {'key': 'properties.requiresDuplicateDetection', 'type': 'bool'}, - 'duplicate_detection_history_time_window': {'key': 'properties.duplicateDetectionHistoryTimeWindow', 'type': 'duration'}, - 'enable_batched_operations': {'key': 'properties.enableBatchedOperations', 'type': 'bool'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'support_ordering': {'key': 'properties.supportOrdering', 'type': 'bool'}, - 'auto_delete_on_idle': {'key': 'properties.autoDeleteOnIdle', 'type': 'duration'}, - 'enable_partitioning': {'key': 'properties.enablePartitioning', 'type': 'bool'}, - 'enable_express': {'key': 'properties.enableExpress', 'type': 'bool'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "size_in_bytes": {"key": "properties.sizeInBytes", "type": "int"}, + "created_at": {"key": "properties.createdAt", "type": "iso-8601"}, + "updated_at": {"key": "properties.updatedAt", "type": "iso-8601"}, + "accessed_at": {"key": "properties.accessedAt", "type": "iso-8601"}, + "subscription_count": {"key": "properties.subscriptionCount", "type": "int"}, + "count_details": {"key": "properties.countDetails", "type": "MessageCountDetails"}, + "default_message_time_to_live": {"key": "properties.defaultMessageTimeToLive", "type": "duration"}, + "max_size_in_megabytes": {"key": "properties.maxSizeInMegabytes", "type": "int"}, + "max_message_size_in_kilobytes": {"key": "properties.maxMessageSizeInKilobytes", "type": "int"}, + "requires_duplicate_detection": {"key": "properties.requiresDuplicateDetection", "type": "bool"}, + "duplicate_detection_history_time_window": { + "key": "properties.duplicateDetectionHistoryTimeWindow", + "type": "duration", + }, + "enable_batched_operations": {"key": "properties.enableBatchedOperations", "type": "bool"}, + "status": {"key": "properties.status", "type": "str"}, + "support_ordering": {"key": "properties.supportOrdering", "type": "bool"}, + "auto_delete_on_idle": {"key": "properties.autoDeleteOnIdle", "type": "duration"}, + "enable_partitioning": {"key": "properties.enablePartitioning", "type": "bool"}, + "enable_express": {"key": "properties.enableExpress", "type": "bool"}, } def __init__( @@ -2743,7 +2636,7 @@ def __init__( :paramtype max_size_in_megabytes: int :keyword max_message_size_in_kilobytes: Maximum size (in KB) of the message payload that can be accepted by the topic. This property is only used in Premium today and default is 1024. - :paramtype max_message_size_in_kilobytes: long + :paramtype max_message_size_in_kilobytes: int :keyword requires_duplicate_detection: Value indicating if this topic requires duplicate detection. :paramtype requires_duplicate_detection: bool @@ -2755,7 +2648,7 @@ def __init__( :paramtype enable_batched_operations: bool :keyword status: Enumerates the possible values for the status of a messaging entity. Known values are: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", "Creating", - "Deleting", "Renaming", "Unknown". + "Deleting", "Renaming", and "Unknown". :paramtype status: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.EntityStatus :keyword support_ordering: Value that indicates whether the topic supports ordering. :paramtype support_ordering: bool @@ -2769,7 +2662,7 @@ def __init__( topic holds a message in memory temporarily before writing it to persistent storage. :paramtype enable_express: bool """ - super(SBTopic, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.size_in_bytes = None self.created_at = None @@ -2790,7 +2683,7 @@ def __init__( self.enable_express = enable_express -class SBTopicListResult(msrest.serialization.Model): +class SBTopicListResult(_serialization.Model): """The response to the List Topics operation. :ivar value: Result of the List Topics operation. @@ -2801,17 +2694,11 @@ class SBTopicListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[SBTopic]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SBTopic]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["_models.SBTopic"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.SBTopic"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: Result of the List Topics operation. :paramtype value: list[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBTopic] @@ -2819,12 +2706,12 @@ def __init__( list of topics. :paramtype next_link: str """ - super(SBTopicListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class SqlFilter(msrest.serialization.Model): +class SqlFilter(_serialization.Model): """Represents a filter which is a composition of an expression and an action that is executed in the pub/sub pipeline. :ivar sql_expression: The SQL expression. e.g. MyProperty='ABC'. @@ -2838,9 +2725,9 @@ class SqlFilter(msrest.serialization.Model): """ _attribute_map = { - 'sql_expression': {'key': 'sqlExpression', 'type': 'str'}, - 'compatibility_level': {'key': 'compatibilityLevel', 'type': 'int'}, - 'requires_preprocessing': {'key': 'requiresPreprocessing', 'type': 'bool'}, + "sql_expression": {"key": "sqlExpression", "type": "str"}, + "compatibility_level": {"key": "compatibilityLevel", "type": "int"}, + "requires_preprocessing": {"key": "requiresPreprocessing", "type": "bool"}, } def __init__( @@ -2848,7 +2735,7 @@ def __init__( *, sql_expression: Optional[str] = None, compatibility_level: Optional[int] = None, - requires_preprocessing: Optional[bool] = True, + requires_preprocessing: bool = True, **kwargs ): """ @@ -2861,7 +2748,7 @@ def __init__( preprocessing. :paramtype requires_preprocessing: bool """ - super(SqlFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.sql_expression = sql_expression self.compatibility_level = compatibility_level self.requires_preprocessing = requires_preprocessing @@ -2881,9 +2768,9 @@ class SqlRuleAction(Action): """ _attribute_map = { - 'sql_expression': {'key': 'sqlExpression', 'type': 'str'}, - 'compatibility_level': {'key': 'compatibilityLevel', 'type': 'int'}, - 'requires_preprocessing': {'key': 'requiresPreprocessing', 'type': 'bool'}, + "sql_expression": {"key": "sqlExpression", "type": "str"}, + "compatibility_level": {"key": "compatibilityLevel", "type": "int"}, + "requires_preprocessing": {"key": "requiresPreprocessing", "type": "bool"}, } def __init__( @@ -2891,7 +2778,7 @@ def __init__( *, sql_expression: Optional[str] = None, compatibility_level: Optional[int] = None, - requires_preprocessing: Optional[bool] = True, + requires_preprocessing: bool = True, **kwargs ): """ @@ -2904,47 +2791,47 @@ def __init__( preprocessing. :paramtype requires_preprocessing: bool """ - super(SqlRuleAction, self).__init__(sql_expression=sql_expression, compatibility_level=compatibility_level, requires_preprocessing=requires_preprocessing, **kwargs) + super().__init__( + sql_expression=sql_expression, + compatibility_level=compatibility_level, + requires_preprocessing=requires_preprocessing, + **kwargs + ) -class Subnet(msrest.serialization.Model): +class Subnet(_serialization.Model): """Properties supplied for Subnet. All required parameters must be populated in order to send to Azure. - :ivar id: Required. Resource ID of Virtual Network Subnet. + :ivar id: Resource ID of Virtual Network Subnet. Required. :vartype id: str """ _validation = { - 'id': {'required': True}, + "id": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - *, - id: str, - **kwargs - ): + def __init__(self, *, id: str, **kwargs): # pylint: disable=redefined-builtin """ - :keyword id: Required. Resource ID of Virtual Network Subnet. + :keyword id: Resource ID of Virtual Network Subnet. Required. :paramtype id: str """ - super(Subnet, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id -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. Known values are: - "User", "Application", "ManagedIdentity", "Key". + "User", "Application", "ManagedIdentity", and "Key". :vartype created_by_type: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.CreatedByType :ivar created_at: The timestamp of resource creation (UTC). @@ -2952,7 +2839,7 @@ class SystemData(msrest.serialization.Model): :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", "Key". + are: "User", "Application", "ManagedIdentity", and "Key". :vartype last_modified_by_type: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.CreatedByType :ivar last_modified_at: The type of identity that last modified the resource. @@ -2960,12 +2847,12 @@ class SystemData(msrest.serialization.Model): """ _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__( @@ -2983,7 +2870,7 @@ def __init__( :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", "Key". + "User", "Application", "ManagedIdentity", and "Key". :paramtype created_by_type: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.CreatedByType :keyword created_at: The timestamp of resource creation (UTC). @@ -2991,13 +2878,13 @@ def __init__( :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", "Key". + values are: "User", "Application", "ManagedIdentity", and "Key". :paramtype last_modified_by_type: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.CreatedByType :keyword last_modified_at: The type of identity that last modified the resource. :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 @@ -3006,7 +2893,7 @@ def __init__( self.last_modified_at = last_modified_at -class UserAssignedIdentity(msrest.serialization.Model): +class UserAssignedIdentity(_serialization.Model): """Recognized Dictionary value. Variables are only populated by the server, and will be ignored when sending a request. @@ -3018,27 +2905,23 @@ class UserAssignedIdentity(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(UserAssignedIdentity, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.principal_id = None self.client_id = None -class UserAssignedIdentityProperties(msrest.serialization.Model): +class UserAssignedIdentityProperties(_serialization.Model): """UserAssignedIdentityProperties. :ivar user_assigned_identity: ARM ID of user Identity selected for encryption. @@ -3046,18 +2929,13 @@ class UserAssignedIdentityProperties(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: ARM ID of user Identity selected for encryption. :paramtype user_assigned_identity: str """ - super(UserAssignedIdentityProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.user_assigned_identity = user_assigned_identity diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/models/_patch.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/models/_patch.py index 0ad201a8c586e..f7dd32510333d 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/models/_patch.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/models/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/models/_service_bus_management_client_enums.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/models/_service_bus_management_client_enums.py index 33112c2ab17d4..ce716a0147196 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/models/_service_bus_management_client_enums.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/models/_service_bus_management_client_enums.py @@ -11,30 +11,31 @@ class AccessRights(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """AccessRights.""" MANAGE = "Manage" SEND = "Send" LISTEN = "Listen" + class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of identity that created the resource. - """ + """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 - """ + """Default Action for Network Rule Set.""" ALLOW = "Allow" DENY = "Deny" + class EndPointProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Provisioning state of the Private Endpoint Connection. - """ + """Provisioning state of the Private Endpoint Connection.""" CREATING = "Creating" UPDATING = "Updating" @@ -43,9 +44,9 @@ class EndPointProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): CANCELED = "Canceled" FAILED = "Failed" + class EntityStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Entity status. - """ + """Entity status.""" ACTIVE = "Active" DISABLED = "Disabled" @@ -57,92 +58,96 @@ class EntityStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): RENAMING = "Renaming" UNKNOWN = "Unknown" + class FilterType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Rule filter types - """ + """Rule filter types.""" SQL_FILTER = "SqlFilter" CORRELATION_FILTER = "CorrelationFilter" + class KeyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The access key to regenerate. - """ + """The access key to regenerate.""" PRIMARY_KEY = "PrimaryKey" SECONDARY_KEY = "SecondaryKey" + class ManagedServiceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Type of managed service identity. - """ + """Type of managed service identity.""" SYSTEM_ASSIGNED = "SystemAssigned" USER_ASSIGNED = "UserAssigned" SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" NONE = "None" + class MigrationConfigurationName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """MigrationConfigurationName.""" _DEFAULT = "$default" + class NetworkRuleIPAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The IP Filter Action - """ + """The IP Filter Action.""" ALLOW = "Allow" + class PrivateLinkConnectionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Status of the connection. - """ + """Status of the connection.""" PENDING = "Pending" APPROVED = "Approved" REJECTED = "Rejected" DISCONNECTED = "Disconnected" + class ProvisioningStateDR(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Provisioning state of the Alias(Disaster Recovery configuration) - possible values 'Accepted' - or 'Succeeded' or 'Failed' + or 'Succeeded' or 'Failed'. """ ACCEPTED = "Accepted" SUCCEEDED = "Succeeded" FAILED = "Failed" + class PublicNetworkAccessFlag(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """This determines if traffic is allowed over public network. By default it is enabled. - """ + """This determines if traffic is allowed over public network. By default it is enabled.""" ENABLED = "Enabled" DISABLED = "Disabled" + class RoleDisasterRecovery(str, Enum, metaclass=CaseInsensitiveEnumMeta): """role of namespace in GEO DR - possible values 'Primary' or 'PrimaryNotReplicating' or - 'Secondary' + 'Secondary'. """ PRIMARY = "Primary" PRIMARY_NOT_REPLICATING = "PrimaryNotReplicating" SECONDARY = "Secondary" + class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Name of this SKU. - """ + """Name of this SKU.""" BASIC = "Basic" STANDARD = "Standard" PREMIUM = "Premium" + class SkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The billing tier of this particular SKU. - """ + """The billing tier of this particular SKU.""" BASIC = "Basic" STANDARD = "Standard" PREMIUM = "Premium" + class UnavailableReason(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the reason for the unavailability of the service. - """ + """Specifies the reason for the unavailability of the service.""" NONE = "None" INVALID_NAME = "InvalidName" diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/operations/__init__.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/operations/__init__.py index 5559ccd3746c6..e5431803c533c 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/operations/__init__.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/operations/__init__.py @@ -18,19 +18,20 @@ from ._subscriptions_operations import SubscriptionsOperations from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'NamespacesOperations', - 'PrivateEndpointConnectionsOperations', - 'PrivateLinkResourcesOperations', - 'Operations', - 'DisasterRecoveryConfigsOperations', - 'MigrationConfigsOperations', - 'QueuesOperations', - 'TopicsOperations', - 'RulesOperations', - 'SubscriptionsOperations', + "NamespacesOperations", + "PrivateEndpointConnectionsOperations", + "PrivateLinkResourcesOperations", + "Operations", + "DisasterRecoveryConfigsOperations", + "MigrationConfigsOperations", + "QueuesOperations", + "TopicsOperations", + "RulesOperations", + "SubscriptionsOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/operations/_disaster_recovery_configs_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/operations/_disaster_recovery_configs_operations.py index b76be6f453d7c..34addb026b5e3 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/operations/_disaster_recovery_configs_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/operations/_disaster_recovery_configs_operations.py @@ -6,11 +6,18 @@ # 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 msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,343 +27,313 @@ 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') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_check_name_availability_request( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - *, - json: Optional[_models.CheckNameAvailability] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_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-06-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: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/CheckNameAvailability") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/CheckNameAvailability", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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, - 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_request( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_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-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _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, - namespace_name: str, - alias: str, - subscription_id: str, - *, - json: Optional[_models.ArmDisasterRecovery] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_name: str, alias: 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-06-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: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "alias": _SERIALIZER.url("alias", alias, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "alias": _SERIALIZER.url("alias", alias, "str", max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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, - 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( - resource_group_name: str, - namespace_name: str, - alias: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, alias: 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-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "alias": _SERIALIZER.url("alias", alias, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "alias": _SERIALIZER.url("alias", alias, "str", max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - namespace_name: str, - alias: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, alias: 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-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "alias": _SERIALIZER.url("alias", alias, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "alias": _SERIALIZER.url("alias", alias, "str", max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_break_pairing_request( - resource_group_name: str, - namespace_name: str, - alias: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, alias: 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-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/breakPairing") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/breakPairing", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "alias": _SERIALIZER.url("alias", alias, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "alias": _SERIALIZER.url("alias", alias, "str", max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_fail_over_request( - resource_group_name: str, - namespace_name: str, - alias: str, - subscription_id: str, - *, - json: Optional[_models.FailoverProperties] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_name: str, alias: 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-06-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: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/failover") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/failover", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "alias": _SERIALIZER.url("alias", alias, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "alias": _SERIALIZER.url("alias", alias, "str", max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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, - 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_authorization_rules_request( - resource_group_name: str, - namespace_name: str, - alias: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, alias: 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-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "alias": _SERIALIZER.url("alias", alias, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "alias": _SERIALIZER.url("alias", alias, "str", max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_authorization_rule_request( @@ -370,34 +347,37 @@ def build_get_authorization_rule_request( _headers = case_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-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules/{authorizationRuleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "alias": _SERIALIZER.url("alias", alias, 'str', max_length=50, min_length=1), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "alias": _SERIALIZER.url("alias", alias, "str", max_length=50, min_length=1), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_keys_request( @@ -411,34 +391,38 @@ def build_list_keys_request( _headers = case_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-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules/{authorizationRuleName}/listKeys") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules/{authorizationRuleName}/listKeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "alias": _SERIALIZER.url("alias", alias, 'str', max_length=50, min_length=1), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "alias": _SERIALIZER.url("alias", alias, "str", max_length=50, min_length=1), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + class DisasterRecoveryConfigsOperations: """ @@ -459,41 +443,109 @@ def __init__(self, *args, **kwargs): 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 + @overload def check_name_availability( self, resource_group_name: str, namespace_name: str, parameters: _models.CheckNameAvailability, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Check the give namespace name availability. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: Parameters to check availability of the given namespace name. + :param parameters: Parameters to check availability of the given namespace name. Required. :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.CheckNameAvailability + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckNameAvailabilityResult or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters to check availability of the given namespace name. Required. + :type 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: CheckNameAvailabilityResult or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_name_availability( + self, + resource_group_name: str, + namespace_name: str, + parameters: Union[_models.CheckNameAvailability, IO], + **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters to check availability of the given namespace name. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.CheckNameAvailability 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: CheckNameAvailabilityResult, or the result of cls(response) + :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.CheckNameAvailabilityResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.CheckNameAvailabilityResult] - - _json = self._serialize.body(parameters, 'CheckNameAvailability') + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CheckNameAvailabilityResult] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "CheckNameAvailability") request = build_check_name_availability_request( resource_group_name=resource_group_name, @@ -502,18 +554,18 @@ def check_name_availability( 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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -521,74 +573,79 @@ def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) + deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/CheckNameAvailability"} # type: ignore - + check_name_availability.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/CheckNameAvailability" + } @distributed_trace def list( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> Iterable[_models.ArmDisasterRecoveryListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> Iterable["_models.ArmDisasterRecovery"]: """Gets all Alias(Disaster Recovery configurations). - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ArmDisasterRecoveryListResult or the result of - cls(response) + :return: An iterator like instance of either ArmDisasterRecovery or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.ArmDisasterRecoveryListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.ArmDisasterRecovery] + :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', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ArmDisasterRecoveryListResult] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.ArmDisasterRecoveryListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -596,16 +653,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("ArmDisasterRecoveryListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -616,49 +671,126 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs" + } - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, namespace_name: str, alias: str, parameters: _models.ArmDisasterRecovery, + *, + content_type: str = "application/json", **kwargs: Any ) -> Optional[_models.ArmDisasterRecovery]: """Creates or updates a new Alias(Disaster Recovery configuration). - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: str :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). + Required. :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.ArmDisasterRecovery + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ArmDisasterRecovery, or the result of cls(response) + :return: ArmDisasterRecovery or None or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.ArmDisasterRecovery or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + alias: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> Optional[_models.ArmDisasterRecovery]: + """Creates or updates a new Alias(Disaster Recovery configuration). + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: str + :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). + Required. + :type 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: ArmDisasterRecovery or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.ArmDisasterRecovery or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + alias: str, + parameters: Union[_models.ArmDisasterRecovery, IO], + **kwargs: Any + ) -> Optional[_models.ArmDisasterRecovery]: + """Creates or updates a new Alias(Disaster Recovery configuration). + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: str + :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). Is + either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.ArmDisasterRecovery 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: ArmDisasterRecovery or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.ArmDisasterRecovery or None + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ArmDisasterRecovery]] - - _json = self._serialize.body(parameters, 'ArmDisasterRecovery') + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.ArmDisasterRecovery]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ArmDisasterRecovery") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -668,18 +800,18 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - 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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -689,67 +821,67 @@ def create_or_update( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ArmDisasterRecovery', pipeline_response) + deserialized = self._deserialize("ArmDisasterRecovery", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}"} # type: ignore - + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}" + } @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - alias: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, alias: str, **kwargs: Any ) -> None: """Deletes an Alias(Disaster Recovery configuration). - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: 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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, alias=alias, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -760,60 +892,60 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}"} # type: ignore - + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}" + } @distributed_trace def get( - self, - resource_group_name: str, - namespace_name: str, - alias: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, alias: str, **kwargs: Any ) -> _models.ArmDisasterRecovery: """Retrieves Alias(Disaster Recovery configuration) for primary or secondary namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ArmDisasterRecovery, or the result of cls(response) + :return: ArmDisasterRecovery or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.ArmDisasterRecovery - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ArmDisasterRecovery] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.ArmDisasterRecovery] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, alias=alias, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -821,68 +953,68 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ArmDisasterRecovery', pipeline_response) + deserialized = self._deserialize("ArmDisasterRecovery", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}" + } @distributed_trace def break_pairing( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - alias: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, alias: str, **kwargs: Any ) -> None: """This operation disables the Disaster Recovery and stops replicating changes from primary to secondary namespaces. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: 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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_break_pairing_request( resource_group_name=resource_group_name, namespace_name=namespace_name, alias=alias, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.break_pairing.metadata['url'], + template_url=self.break_pairing.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -893,50 +1025,127 @@ def break_pairing( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - break_pairing.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/breakPairing"} # type: ignore - + break_pairing.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/breakPairing" + } - @distributed_trace + @overload def fail_over( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, alias: str, parameters: Optional[_models.FailoverProperties] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> None: """Invokes GEO DR failover and reconfigure the alias to point to the secondary namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: str :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). Default value is None. :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.FailoverProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default 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: + """ + + @overload + def fail_over( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + namespace_name: str, + alias: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Invokes GEO DR failover and reconfigure the alias to point to the secondary namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: str + :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). + Default value is None. + :type 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: 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: + """ + + @distributed_trace + def fail_over( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + namespace_name: str, + alias: str, + parameters: Optional[Union[_models.FailoverProperties, IO]] = None, + **kwargs: Any + ) -> None: + """Invokes GEO DR failover and reconfigure the alias to point to the secondary namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: str + :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). Is + either a model type or a IO type. Default value is None. + :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.FailoverProperties 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: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[None] - - if parameters is not None: - _json = self._serialize.body(parameters, 'FailoverProperties') + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "FailoverProperties") + else: + _json = None request = build_fail_over_request( resource_group_name=resource_group_name, @@ -946,18 +1155,18 @@ def fail_over( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, json=_json, - template_url=self.fail_over.metadata['url'], + content=_content, + template_url=self.fail_over.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -968,72 +1177,75 @@ def fail_over( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - fail_over.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/failover"} # type: ignore - + fail_over.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/failover" + } @distributed_trace def list_authorization_rules( - self, - resource_group_name: str, - namespace_name: str, - alias: str, - **kwargs: Any - ) -> Iterable[_models.SBAuthorizationRuleListResult]: + self, resource_group_name: str, namespace_name: str, alias: str, **kwargs: Any + ) -> Iterable["_models.SBAuthorizationRule"]: """Gets the authorization rules for a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of - cls(response) + :return: An iterator like instance of either SBAuthorizationRule or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRule] + :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', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRuleListResult] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.SBAuthorizationRuleListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_authorization_rules_request( resource_group_name=resource_group_name, namespace_name=namespace_name, alias=alias, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_authorization_rules.metadata['url'], + template_url=self.list_authorization_rules.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_authorization_rules_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - alias=alias, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -1041,16 +1253,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("SBAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1061,48 +1271,47 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_authorization_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules"} # type: ignore + list_authorization_rules.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules" + } @distributed_trace def get_authorization_rule( - self, - resource_group_name: str, - namespace_name: str, - alias: str, - authorization_rule_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, alias: str, authorization_rule_name: str, **kwargs: Any ) -> _models.SBAuthorizationRule: """Gets an authorization rule for a namespace by rule name. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.SBAuthorizationRule] = kwargs.pop("cls", None) - request = build_get_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -1110,18 +1319,17 @@ def get_authorization_rule( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_authorization_rule.metadata['url'], + template_url=self.get_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1129,52 +1337,52 @@ def get_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules/{authorizationRuleName}"} # type: ignore - + get_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules/{authorizationRuleName}" + } @distributed_trace def list_keys( - self, - resource_group_name: str, - namespace_name: str, - alias: str, - authorization_rule_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, alias: str, authorization_rule_name: str, **kwargs: Any ) -> _models.AccessKeys: """Gets the primary and secondary connection strings for the namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.AccessKeys] = kwargs.pop("cls", None) - request = build_list_keys_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -1182,18 +1390,17 @@ def list_keys( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata['url'], + 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 + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1201,12 +1408,13 @@ def list_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + deserialized = self._deserialize("AccessKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules/{authorizationRuleName}/listKeys"} # type: ignore - + list_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules/{authorizationRuleName}/listKeys" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/operations/_migration_configs_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/operations/_migration_configs_operations.py index 319439294e12c..9eaf7c543a5cd 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/operations/_migration_configs_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/operations/_migration_configs_operations.py @@ -6,11 +6,18 @@ # 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, Union, cast - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -22,251 +29,257 @@ 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') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +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, - namespace_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_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-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_and_start_migration_request_initial( +def build_create_and_start_migration_request( resource_group_name: str, namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], + config_name: Union[str, _models.MigrationConfigurationName], subscription_id: str, - *, - json: Optional[_models.MigrationConfigProperties] = None, - content: Any = 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', "2021-06-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: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "configName": _SERIALIZER.url("config_name", config_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "configName": _SERIALIZER.url("config_name", config_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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, - 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( resource_group_name: str, namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], + config_name: Union[str, _models.MigrationConfigurationName], 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-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "configName": _SERIALIZER.url("config_name", config_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "configName": _SERIALIZER.url("config_name", config_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( resource_group_name: str, namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], + config_name: Union[str, _models.MigrationConfigurationName], 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-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "configName": _SERIALIZER.url("config_name", config_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "configName": _SERIALIZER.url("config_name", config_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_complete_migration_request( resource_group_name: str, namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], + config_name: Union[str, _models.MigrationConfigurationName], 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-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/upgrade") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/upgrade", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "configName": _SERIALIZER.url("config_name", config_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "configName": _SERIALIZER.url("config_name", config_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_revert_request( resource_group_name: str, namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], + config_name: Union[str, _models.MigrationConfigurationName], 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-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/revert") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/revert", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "configName": _SERIALIZER.url("config_name", config_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "configName": _SERIALIZER.url("config_name", config_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + class MigrationConfigsOperations: """ @@ -287,65 +300,69 @@ def __init__(self, *args, **kwargs): 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, - namespace_name: str, - **kwargs: Any - ) -> Iterable[_models.MigrationConfigListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> Iterable["_models.MigrationConfigProperties"]: """Gets all migrationConfigurations. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MigrationConfigListResult or the result of + :return: An iterator like instance of either MigrationConfigProperties or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.MigrationConfigListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.MigrationConfigProperties] + :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', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MigrationConfigListResult] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.MigrationConfigListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -353,16 +370,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("MigrationConfigListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -373,35 +388,46 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations" + } def _create_and_start_migration_initial( self, resource_group_name: str, namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], - parameters: _models.MigrationConfigProperties, + config_name: Union[str, _models.MigrationConfigurationName], + parameters: Union[_models.MigrationConfigProperties, IO], **kwargs: Any ) -> Optional[_models.MigrationConfigProperties]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.MigrationConfigProperties]] - - _json = self._serialize.body(parameters, 'MigrationConfigProperties') - - request = build_create_and_start_migration_request_initial( + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.MigrationConfigProperties]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "MigrationConfigProperties") + + request = build_create_and_start_migration_request( resource_group_name=resource_group_name, namespace_name=namespace_name, config_name=config_name, @@ -409,57 +435,146 @@ def _create_and_start_migration_initial( api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_and_start_migration_initial.metadata['url'], + content=_content, + template_url=self._create_and_start_migration_initial.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('MigrationConfigProperties', pipeline_response) + deserialized = self._deserialize("MigrationConfigProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_and_start_migration_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}"} # type: ignore + _create_and_start_migration_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}" + } + @overload + def begin_create_and_start_migration( + self, + resource_group_name: str, + namespace_name: str, + config_name: Union[str, _models.MigrationConfigurationName], + parameters: _models.MigrationConfigProperties, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.MigrationConfigProperties]: + """Creates Migration configuration and starts migration of entities from Standard to Premium + namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param config_name: The configuration name. Should always be "$default". "$default" Required. + :type config_name: str or + ~azure.mgmt.servicebus.v2021_06_01_preview.models.MigrationConfigurationName + :param parameters: Parameters required to create Migration Configuration. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.MigrationConfigProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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 MigrationConfigProperties or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.servicebus.v2021_06_01_preview.models.MigrationConfigProperties] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_and_start_migration( + self, + resource_group_name: str, + namespace_name: str, + config_name: Union[str, _models.MigrationConfigurationName], + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.MigrationConfigProperties]: + """Creates Migration configuration and starts migration of entities from Standard to Premium + namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param config_name: The configuration name. Should always be "$default". "$default" Required. + :type config_name: str or + ~azure.mgmt.servicebus.v2021_06_01_preview.models.MigrationConfigurationName + :param parameters: Parameters required to create Migration Configuration. Required. + :type 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 + :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 MigrationConfigProperties or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.servicebus.v2021_06_01_preview.models.MigrationConfigProperties] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_and_start_migration( self, resource_group_name: str, namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], - parameters: _models.MigrationConfigProperties, + config_name: Union[str, _models.MigrationConfigurationName], + parameters: Union[_models.MigrationConfigProperties, IO], **kwargs: Any ) -> LROPoller[_models.MigrationConfigProperties]: """Creates Migration configuration and starts migration of entities from Standard to Premium namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :type config_name: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.MigrationConfigurationName - :param parameters: Parameters required to create Migration Configuration. + :param parameters: Parameters required to create Migration Configuration. Is either a model + type or a IO type. Required. :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.MigrationConfigProperties + 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 @@ -472,114 +587,114 @@ def begin_create_and_start_migration( of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.servicebus.v2021_06_01_preview.models.MigrationConfigProperties] - :raises: ~azure.core.exceptions.HttpResponseError + :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-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.MigrationConfigProperties] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.MigrationConfigProperties] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._create_and_start_migration_initial( # type: ignore + raw_result = self._create_and_start_migration_initial( resource_group_name=resource_group_name, namespace_name=namespace_name, config_name=config_name, parameters=parameters, 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): - deserialized = self._deserialize('MigrationConfigProperties', pipeline_response) + deserialized = self._deserialize("MigrationConfigProperties", 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 + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create_and_start_migration.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}"} # type: ignore + begin_create_and_start_migration.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}" + } @distributed_trace def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], + config_name: Union[str, _models.MigrationConfigurationName], **kwargs: Any ) -> None: """Deletes a MigrationConfiguration. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :type config_name: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.MigrationConfigurationName :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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, config_name=config_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -590,61 +705,65 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}"} # type: ignore - + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}" + } @distributed_trace def get( self, resource_group_name: str, namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], + config_name: Union[str, _models.MigrationConfigurationName], **kwargs: Any ) -> _models.MigrationConfigProperties: """Retrieves Migration Config. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :type config_name: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.MigrationConfigurationName :keyword callable cls: A custom type or function that will be passed the direct response - :return: MigrationConfigProperties, or the result of cls(response) + :return: MigrationConfigProperties or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.MigrationConfigProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MigrationConfigProperties] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.MigrationConfigProperties] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, config_name=config_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -652,70 +771,74 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('MigrationConfigProperties', pipeline_response) + deserialized = self._deserialize("MigrationConfigProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}" + } @distributed_trace def complete_migration( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], + config_name: Union[str, _models.MigrationConfigurationName], **kwargs: Any ) -> None: """This operation Completes Migration of entities by pointing the connection strings to Premium namespace and any entities created after the operation will be under Premium Namespace. CompleteMigration operation will fail when entity migration is in-progress. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :type config_name: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.MigrationConfigurationName :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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_complete_migration_request( resource_group_name=resource_group_name, namespace_name=namespace_name, config_name=config_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.complete_migration.metadata['url'], + template_url=self.complete_migration.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -726,61 +849,65 @@ def complete_migration( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - complete_migration.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/upgrade"} # type: ignore - + complete_migration.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/upgrade" + } @distributed_trace def revert( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], + config_name: Union[str, _models.MigrationConfigurationName], **kwargs: Any ) -> None: """This operation reverts Migration. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :type config_name: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.MigrationConfigurationName :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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_revert_request( resource_group_name=resource_group_name, namespace_name=namespace_name, config_name=config_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.revert.metadata['url'], + template_url=self.revert.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -791,5 +918,6 @@ def revert( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - revert.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/revert"} # type: ignore - + revert.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/revert" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/operations/_namespaces_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/operations/_namespaces_operations.py index 8157c9b729a33..b44c663070d6e 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/operations/_namespaces_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/operations/_namespaces_operations.py @@ -6,11 +6,18 @@ # 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, Union, cast - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -22,651 +29,593 @@ 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') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +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, - **kwargs: Any -) -> HttpRequest: + +def build_list_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-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/namespaces") 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: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _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: + +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-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _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( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - *, - json: Optional[_models.SBNamespace] = None, - content: Any = None, - **kwargs: Any + +def build_create_or_update_request( + resource_group_name: str, namespace_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-06-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: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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, - 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( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - **kwargs: Any + +def build_delete_request( + resource_group_name: str, namespace_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-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_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-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _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, - namespace_name: str, - subscription_id: str, - *, - json: Optional[_models.SBNamespaceUpdateParameters] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_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-06-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: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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, - 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_create_or_update_network_rule_set_request( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - *, - json: Optional[_models.NetworkRuleSet] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_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-06-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: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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, - 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_get_network_rule_set_request( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_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-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_network_rule_sets_request( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_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-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_authorization_rules_request( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_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-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_authorization_rule_request( - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - subscription_id: str, - *, - json: Optional[_models.SBAuthorizationRule] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_name: str, authorization_rule_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-06-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: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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, - 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_authorization_rule_request( - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, authorization_rule_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-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_authorization_rule_request( - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, authorization_rule_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-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_keys_request( - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, authorization_rule_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-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/listKeys") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/listKeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_regenerate_keys_request( - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - subscription_id: str, - *, - json: Optional[_models.RegenerateAccessKeyParameters] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_name: str, authorization_rule_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-06-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: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/regenerateKeys") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/regenerateKeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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, - 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_check_name_availability_request( - subscription_id: str, - *, - json: Optional[_models.CheckNameAvailability] = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: + +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-06-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: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/CheckNameAvailability") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/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: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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, - 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 NamespacesOperations: """ @@ -687,55 +636,60 @@ def __init__(self, *args, **kwargs): 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.SBNamespaceListResult]: + def list(self, **kwargs: Any) -> Iterable["_models.SBNamespace"]: """Gets all the available namespaces within the subscription, irrespective of the resource groups. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBNamespaceListResult or the result of - cls(response) + :return: An iterator like instance of either SBNamespace or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBNamespaceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBNamespace] + :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', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBNamespaceListResult] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.SBNamespaceListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -743,16 +697,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("SBNamespaceListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -763,65 +715,67 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/namespaces"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/namespaces"} @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable[_models.SBNamespaceListResult]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.SBNamespace"]: """Gets the available namespaces within a resource group. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. 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 SBNamespaceListResult or the result of - cls(response) + :return: An iterator like instance of either SBNamespace or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBNamespaceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBNamespace] + :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', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBNamespaceListResult] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.SBNamespaceListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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'], + 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 + request.url = self._client.format_url(request.url) else: - - 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=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -829,16 +783,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("SBNamespaceListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -849,90 +801,141 @@ 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.ServiceBus/namespaces"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces" + } def _create_or_update_initial( - self, - resource_group_name: str, - namespace_name: str, - parameters: _models.SBNamespace, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, parameters: Union[_models.SBNamespace, IO], **kwargs: Any ) -> Optional[_models.SBNamespace]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.SBNamespace]] - - _json = self._serialize.body(parameters, 'SBNamespace') - - request = build_create_or_update_request_initial( + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.SBNamespace]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBNamespace") + + request = build_create_or_update_request( resource_group_name=resource_group_name, namespace_name=namespace_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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('SBNamespace', pipeline_response) + deserialized = self._deserialize("SBNamespace", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('SBNamespace', pipeline_response) + deserialized = self._deserialize("SBNamespace", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore - + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}" + } - @distributed_trace + @overload def begin_create_or_update( self, resource_group_name: str, namespace_name: str, parameters: _models.SBNamespace, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.SBNamespace]: """Creates or updates a service namespace. Once created, this namespace's resource manifest is immutable. This operation is idempotent. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: Parameters supplied to create a namespace resource. + :param parameters: Parameters supplied to create a namespace resource. Required. :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBNamespace + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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 SBNamespace or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBNamespace] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.SBNamespace]: + """Creates or updates a service namespace. Once created, this namespace's resource manifest is + immutable. This operation is idempotent. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to create a namespace resource. Required. + :type 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 :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 @@ -945,121 +948,147 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBNamespace] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, resource_group_name: str, namespace_name: str, parameters: Union[_models.SBNamespace, IO], **kwargs: Any + ) -> LROPoller[_models.SBNamespace]: + """Creates or updates a service namespace. Once created, this namespace's resource manifest is + immutable. This operation is idempotent. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to create a namespace resource. Is either a model type + or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBNamespace 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 SBNamespace or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBNamespace] + :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-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBNamespace] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SBNamespace] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._create_or_update_initial( # type: ignore + raw_result = self._create_or_update_initial( resource_group_name=resource_group_name, namespace_name=namespace_name, parameters=parameters, 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): - deserialized = self._deserialize('SBNamespace', pipeline_response) + deserialized = self._deserialize("SBNamespace", 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 + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}" + } def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, **kwargs: Any ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request_initial( + request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + 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 + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}" + } @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete(self, resource_group_name: str, namespace_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes an existing namespace. This operation also removes all associated resources under the namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_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. @@ -1071,103 +1100,98 @@ def begin_delete( # pylint: disable=inconsistent-return-statements 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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: 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 + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, namespace_name=namespace_name, api_version=api_version, - 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 = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}" + } @distributed_trace - def get( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> _models.SBNamespace: + def get(self, resource_group_name: str, namespace_name: str, **kwargs: Any) -> _models.SBNamespace: """Gets a description for the specified namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBNamespace, or the result of cls(response) + :return: SBNamespace or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBNamespace - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBNamespace] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.SBNamespace] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1175,51 +1199,124 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBNamespace', pipeline_response) + deserialized = self._deserialize("SBNamespace", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}" + } + + @overload + def update( + self, + resource_group_name: str, + namespace_name: str, + parameters: _models.SBNamespaceUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> Optional[_models.SBNamespace]: + """Updates a service namespace. Once created, this namespace's resource manifest is immutable. + This operation is idempotent. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to update a namespace resource. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBNamespaceUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBNamespace or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBNamespace or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> Optional[_models.SBNamespace]: + """Updates a service namespace. Once created, this namespace's resource manifest is immutable. + This operation is idempotent. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to update a namespace resource. Required. + :type 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: SBNamespace or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBNamespace or None + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def update( self, resource_group_name: str, namespace_name: str, - parameters: _models.SBNamespaceUpdateParameters, + parameters: Union[_models.SBNamespaceUpdateParameters, IO], **kwargs: Any ) -> Optional[_models.SBNamespace]: """Updates a service namespace. Once created, this namespace's resource manifest is immutable. This operation is idempotent. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: Parameters supplied to update a namespace resource. + :param parameters: Parameters supplied to update a namespace resource. Is either a model type + or a IO type. Required. :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBNamespaceUpdateParameters + 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: SBNamespace, or the result of cls(response) + :return: SBNamespace or None or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBNamespace or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.SBNamespace]] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.SBNamespace]] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'SBNamespaceUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBNamespaceUpdateParameters") request = build_update_request( resource_group_name=resource_group_name, @@ -1228,18 +1325,18 @@ def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -1249,53 +1346,122 @@ def update( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('SBNamespace', pipeline_response) + deserialized = self._deserialize("SBNamespace", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('SBNamespace', pipeline_response) + deserialized = self._deserialize("SBNamespace", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore - + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}" + } - @distributed_trace + @overload def create_or_update_network_rule_set( self, resource_group_name: str, namespace_name: str, parameters: _models.NetworkRuleSet, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.NetworkRuleSet: """Create or update NetworkRuleSet for a Namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: The Namespace IpFilterRule. + :param parameters: The Namespace IpFilterRule. Required. :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.NetworkRuleSet + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: NetworkRuleSet, or the result of cls(response) + :return: NetworkRuleSet or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.NetworkRuleSet - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_network_rule_set( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.NetworkRuleSet: + """Create or update NetworkRuleSet for a Namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: The Namespace IpFilterRule. Required. + :type 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: NetworkRuleSet or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.NetworkRuleSet + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update_network_rule_set( + self, + resource_group_name: str, + namespace_name: str, + parameters: Union[_models.NetworkRuleSet, IO], + **kwargs: Any + ) -> _models.NetworkRuleSet: + """Create or update NetworkRuleSet for a Namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: The Namespace IpFilterRule. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.NetworkRuleSet 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: NetworkRuleSet or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.NetworkRuleSet + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.NetworkRuleSet] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.NetworkRuleSet] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'NetworkRuleSet') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "NetworkRuleSet") request = build_create_or_update_network_rule_set_request( resource_group_name=resource_group_name, @@ -1304,18 +1470,18 @@ def create_or_update_network_rule_set( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_network_rule_set.metadata['url'], + content=_content, + template_url=self.create_or_update_network_rule_set.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1323,63 +1489,64 @@ def create_or_update_network_rule_set( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('NetworkRuleSet', pipeline_response) + deserialized = self._deserialize("NetworkRuleSet", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_network_rule_set.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default"} # type: ignore - + create_or_update_network_rule_set.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default" + } @distributed_trace def get_network_rule_set( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, **kwargs: Any ) -> _models.NetworkRuleSet: """Gets NetworkRuleSet for a Namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: NetworkRuleSet, or the result of cls(response) + :return: NetworkRuleSet or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.NetworkRuleSet - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.NetworkRuleSet] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.NetworkRuleSet] = kwargs.pop("cls", None) - request = build_get_network_rule_set_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_network_rule_set.metadata['url'], + template_url=self.get_network_rule_set.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1387,74 +1554,79 @@ def get_network_rule_set( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('NetworkRuleSet', pipeline_response) + deserialized = self._deserialize("NetworkRuleSet", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_network_rule_set.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default"} # type: ignore - + get_network_rule_set.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default" + } @distributed_trace def list_network_rule_sets( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> Iterable[_models.NetworkRuleSetListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> Iterable["_models.NetworkRuleSet"]: """Gets list of NetworkRuleSet for a Namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either NetworkRuleSetListResult or the result of - cls(response) + :return: An iterator like instance of either NetworkRuleSet or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.NetworkRuleSetListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.NetworkRuleSet] + :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', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.NetworkRuleSetListResult] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.NetworkRuleSetListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_network_rule_sets_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_network_rule_sets.metadata['url'], + template_url=self.list_network_rule_sets.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_network_rule_sets_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -1462,16 +1634,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("NetworkRuleSetListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1482,70 +1652,74 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_network_rule_sets.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets"} # type: ignore + list_network_rule_sets.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets" + } @distributed_trace def list_authorization_rules( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> Iterable[_models.SBAuthorizationRuleListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> Iterable["_models.SBAuthorizationRule"]: """Gets the authorization rules for a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of - cls(response) + :return: An iterator like instance of either SBAuthorizationRule or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRule] + :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', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRuleListResult] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.SBAuthorizationRuleListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_authorization_rules_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_authorization_rules.metadata['url'], + template_url=self.list_authorization_rules.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_authorization_rules_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -1553,16 +1727,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("SBAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1573,49 +1745,124 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_authorization_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules"} # type: ignore + list_authorization_rules.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules" + } - @distributed_trace + @overload def create_or_update_authorization_rule( self, resource_group_name: str, namespace_name: str, authorization_rule_name: str, parameters: _models.SBAuthorizationRule, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SBAuthorizationRule: """Creates or updates an authorization rule for a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: The shared access authorization rule. + :param parameters: The shared access authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBAuthorizationRule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates or updates an authorization rule for a namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Required. + :type 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: SBAuthorizationRule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: Union[_models.SBAuthorizationRule, IO], + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates or updates an authorization rule for a namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRule 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: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SBAuthorizationRule] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'SBAuthorizationRule') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBAuthorizationRule") request = build_create_or_update_authorization_rule_request( resource_group_name=resource_group_name, @@ -1625,18 +1872,18 @@ def create_or_update_authorization_rule( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_authorization_rule.metadata['url'], + content=_content, + template_url=self.create_or_update_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1644,67 +1891,67 @@ def create_or_update_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}"} # type: ignore - + create_or_update_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}" + } @distributed_trace def delete_authorization_rule( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, authorization_rule_name: str, **kwargs: Any ) -> None: """Deletes a namespace authorization rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_authorization_rule.metadata['url'], + template_url=self.delete_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1715,60 +1962,60 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}"} # type: ignore - + delete_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}" + } @distributed_trace def get_authorization_rule( - self, - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, authorization_rule_name: str, **kwargs: Any ) -> _models.SBAuthorizationRule: """Gets an authorization rule for a namespace by rule name. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.SBAuthorizationRule] = kwargs.pop("cls", None) - request = build_get_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_authorization_rule.metadata['url'], + template_url=self.get_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1776,67 +2023,67 @@ def get_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}"} # type: ignore - + get_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}" + } @distributed_trace def list_keys( - self, - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, authorization_rule_name: str, **kwargs: Any ) -> _models.AccessKeys: """Gets the primary and secondary connection strings for the namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.AccessKeys] = kwargs.pop("cls", None) - request = build_list_keys_request( resource_group_name=resource_group_name, namespace_name=namespace_name, authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata['url'], + 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 + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1844,54 +2091,131 @@ def list_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + deserialized = self._deserialize("AccessKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/listKeys"} # type: ignore - + list_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/listKeys" + } - @distributed_trace + @overload def regenerate_keys( self, resource_group_name: str, namespace_name: str, authorization_rule_name: str, parameters: _models.RegenerateAccessKeyParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.AccessKeys: """Regenerates the primary or secondary connection strings for the namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate the authorization rule. + :param parameters: Parameters supplied to regenerate the authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.RegenerateAccessKeyParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AccessKeys: + """Regenerates the primary or secondary connection strings for the namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Required. + :type 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: AccessKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: Union[_models.RegenerateAccessKeyParameters, IO], + **kwargs: Any + ) -> _models.AccessKeys: + """Regenerates the primary or secondary connection strings for the namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Is either a model + type or a IO type. Required. + :type parameters: + ~azure.mgmt.servicebus.v2021_06_01_preview.models.RegenerateAccessKeyParameters 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: AccessKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AccessKeys] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RegenerateAccessKeyParameters") request = build_regenerate_keys_request( resource_group_name=resource_group_name, @@ -1901,18 +2225,18 @@ def regenerate_keys( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_keys.metadata['url'], + content=_content, + template_url=self.regenerate_keys.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1920,62 +2244,110 @@ def regenerate_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + deserialized = self._deserialize("AccessKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/regenerateKeys"} # type: ignore + regenerate_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/regenerateKeys" + } + + @overload + def check_name_availability( + self, parameters: _models.CheckNameAvailability, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param parameters: Parameters to check availability of the given namespace name. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.CheckNameAvailability + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckNameAvailabilityResult or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + :param parameters: Parameters to check availability of the given namespace name. Required. + :type 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: CheckNameAvailabilityResult or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def check_name_availability( - self, - parameters: _models.CheckNameAvailability, - **kwargs: Any + self, parameters: Union[_models.CheckNameAvailability, IO], **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Check the give namespace name availability. - :param parameters: Parameters to check availability of the given namespace name. - :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.CheckNameAvailability + :param parameters: Parameters to check availability of the given namespace name. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.CheckNameAvailability 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: CheckNameAvailabilityResult, or the result of cls(response) + :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.CheckNameAvailabilityResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.CheckNameAvailabilityResult] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CheckNameAvailabilityResult] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'CheckNameAvailability') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "CheckNameAvailability") 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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1983,12 +2355,13 @@ def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) + deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/CheckNameAvailability"} # type: ignore - + check_name_availability.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/CheckNameAvailability" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/operations/_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/operations/_operations.py index 638354888069f..c2aa9e48d981e 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/operations/_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/operations/_operations.py @@ -6,11 +6,18 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,38 +27,40 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +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: + +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-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.ServiceBus/operations") # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + class Operations: """ @@ -72,52 +81,59 @@ def __init__(self, *args, **kwargs): 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 ServiceBus 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.paging.ItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_06_01_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', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_request( - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -125,16 +141,14 @@ 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) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -145,8 +159,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.ServiceBus/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.ServiceBus/operations"} diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/operations/_patch.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/operations/_patch.py index 0ad201a8c586e..f7dd32510333d 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/operations/_patch.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/operations/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/operations/_private_endpoint_connections_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/operations/_private_endpoint_connections_operations.py index 4ed15ed51fa42..8f6882d623ad0 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/operations/_private_endpoint_connections_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/operations/_private_endpoint_connections_operations.py @@ -6,11 +6,18 @@ # 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, Union, cast - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -22,134 +29,140 @@ 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') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +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, - namespace_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_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-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( - subscription_id: str, resource_group_name: str, namespace_name: str, private_endpoint_connection_name: str, - *, - json: Optional[_models.PrivateEndpointConnection] = None, - content: Any = None, + 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-06-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: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/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', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "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", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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, - 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( + +def build_delete_request( resource_group_name: str, namespace_name: str, - subscription_id: 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', "2021-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( @@ -162,33 +175,37 @@ def build_get_request( _headers = case_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-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "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", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + class PrivateEndpointConnectionsOperations: """ @@ -209,65 +226,69 @@ def __init__(self, *args, **kwargs): 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, - namespace_name: str, - **kwargs: Any - ) -> Iterable[_models.PrivateEndpointConnectionListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> Iterable["_models.PrivateEndpointConnection"]: """Gets the available PrivateEndpointConnections within a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateEndpointConnectionListResult or the result - of cls(response) + :return: An iterator like instance of either PrivateEndpointConnection or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.PrivateEndpointConnectionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_06_01_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', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnectionListResult] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -275,16 +296,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -295,71 +314,148 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections" + } - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, namespace_name: str, private_endpoint_connection_name: str, parameters: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.PrivateEndpointConnection: """Creates or updates PrivateEndpointConnections of service namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param private_endpoint_connection_name: The PrivateEndpointConnection name. + :param private_endpoint_connection_name: The PrivateEndpointConnection name. Required. :type private_endpoint_connection_name: str :param parameters: Parameters supplied to update Status of PrivateEndPoint Connection to - namespace resource. + namespace resource. Required. :type parameters: ~azure.mgmt.servicebus.v2021_06_01_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 - :return: PrivateEndpointConnection, or the result of cls(response) + :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + private_endpoint_connection_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Creates or updates PrivateEndpointConnections of service namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param private_endpoint_connection_name: The PrivateEndpointConnection name. Required. + :type private_endpoint_connection_name: str + :param parameters: Parameters supplied to update Status of PrivateEndPoint Connection to + namespace resource. Required. + :type 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: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + private_endpoint_connection_name: str, + parameters: Union[_models.PrivateEndpointConnection, IO], + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Creates or updates PrivateEndpointConnections of service namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param private_endpoint_connection_name: The PrivateEndpointConnection name. Required. + :type private_endpoint_connection_name: str + :param parameters: Parameters supplied to update Status of PrivateEndPoint Connection to + namespace resource. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_06_01_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 + :return: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'PrivateEndpointConnection') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PrivateEndpointConnection") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, namespace_name=namespace_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.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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -368,83 +464,81 @@ def create_or_update( 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 cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + return deserialized # type: ignore + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}" + } def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request_initial( + request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, - subscription_id=self._config.subscription_id, 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'], + 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 + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}" + } @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, namespace_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes an existing Private Endpoint Connection. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param private_endpoint_connection_name: The PrivateEndpointConnection name. + :param private_endpoint_connection_name: The PrivateEndpointConnection name. 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. @@ -456,108 +550,104 @@ def begin_delete( # pylint: disable=inconsistent-return-statements 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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: 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 + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, namespace_name=namespace_name, private_endpoint_connection_name=private_endpoint_connection_name, api_version=api_version, - 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 = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}" + } @distributed_trace def get( - self, - resource_group_name: str, - namespace_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> _models.PrivateEndpointConnection: """Gets a description for the specified Private Endpoint Connection. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param private_endpoint_connection_name: The PrivateEndpointConnection name. + :param private_endpoint_connection_name: The PrivateEndpointConnection name. 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.servicebus.v2021_06_01_preview.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_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'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -565,12 +655,13 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, 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.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/operations/_private_link_resources_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/operations/_private_link_resources_operations.py index 572b3efe134ca..9362c24d3fde6 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/operations/_private_link_resources_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/operations/_private_link_resources_operations.py @@ -6,11 +6,17 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Optional, TypeVar -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest @@ -19,48 +25,54 @@ 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') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +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, - namespace_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_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-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateLinkResources") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateLinkResources", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + class PrivateLinkResourcesOperations: """ @@ -81,54 +93,53 @@ def __init__(self, *args, **kwargs): 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, - namespace_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, **kwargs: Any ) -> _models.PrivateLinkResourcesListResult: """Gets lists of resources that supports Privatelinks. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateLinkResourcesListResult, or the result of cls(response) + :return: PrivateLinkResourcesListResult or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.PrivateLinkResourcesListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateLinkResourcesListResult] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.PrivateLinkResourcesListResult] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -136,12 +147,13 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateLinkResourcesListResult', pipeline_response) + deserialized = self._deserialize("PrivateLinkResourcesListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateLinkResources"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateLinkResources" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/operations/_queues_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/operations/_queues_operations.py index a25f0af9205b7..07ae428351085 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/operations/_queues_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/operations/_queues_operations.py @@ -6,11 +6,18 @@ # 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 msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,50 +27,54 @@ 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') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_authorization_rules_request( - resource_group_name: str, - namespace_name: str, - queue_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, queue_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-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_authorization_rule_request( @@ -72,47 +83,45 @@ def build_create_or_update_authorization_rule_request( queue_name: str, authorization_rule_name: str, subscription_id: str, - *, - json: Optional[_models.SBAuthorizationRule] = None, - content: Any = 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', "2021-06-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: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', min_length=1), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, "str", min_length=1), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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, - 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_authorization_rule_request( @@ -126,34 +135,37 @@ def build_delete_authorization_rule_request( _headers = case_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-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', min_length=1), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, "str", min_length=1), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_authorization_rule_request( @@ -167,34 +179,37 @@ def build_get_authorization_rule_request( _headers = case_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-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', min_length=1), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, "str", min_length=1), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_keys_request( @@ -208,34 +223,37 @@ def build_list_keys_request( _headers = case_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-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/ListKeys") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/ListKeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', min_length=1), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, "str", min_length=1), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_regenerate_keys_request( @@ -244,47 +262,45 @@ def build_regenerate_keys_request( queue_name: str, authorization_rule_name: str, subscription_id: str, - *, - json: Optional[_models.RegenerateAccessKeyParameters] = None, - content: Any = 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', "2021-06-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: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/regenerateKeys") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/regenerateKeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', min_length=1), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, "str", min_length=1), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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, - 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_by_namespace_request( @@ -299,161 +315,149 @@ def build_list_by_namespace_request( _headers = case_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-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if skip is not None: - _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', maximum=1000, minimum=0) + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", maximum=1000, minimum=0) if top is not None: - _params['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", maximum=1000, minimum=1) # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **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( - resource_group_name: str, - namespace_name: str, - queue_name: str, - subscription_id: str, - *, - json: Optional[_models.SBQueue] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_name: str, queue_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-06-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: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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, - 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( - resource_group_name: str, - namespace_name: str, - queue_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, queue_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-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - namespace_name: str, - queue_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, queue_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-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + class QueuesOperations: """ @@ -474,70 +478,71 @@ def __init__(self, *args, **kwargs): 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_authorization_rules( - self, - resource_group_name: str, - namespace_name: str, - queue_name: str, - **kwargs: Any - ) -> Iterable[_models.SBAuthorizationRuleListResult]: + self, resource_group_name: str, namespace_name: str, queue_name: str, **kwargs: Any + ) -> Iterable["_models.SBAuthorizationRule"]: """Gets all authorization rules for a queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of - cls(response) + :return: An iterator like instance of either SBAuthorizationRule or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRule] + :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', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRuleListResult] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.SBAuthorizationRuleListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_authorization_rules_request( resource_group_name=resource_group_name, namespace_name=namespace_name, queue_name=queue_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_authorization_rules.metadata['url'], + template_url=self.list_authorization_rules.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_authorization_rules_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - queue_name=queue_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -545,16 +550,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("SBAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -565,13 +568,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_authorization_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules"} # type: ignore + list_authorization_rules.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules" + } - @distributed_trace + @overload def create_or_update_authorization_rule( self, resource_group_name: str, @@ -579,38 +582,119 @@ def create_or_update_authorization_rule( queue_name: str, authorization_rule_name: str, parameters: _models.SBAuthorizationRule, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SBAuthorizationRule: """Creates an authorization rule for a queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: The shared access authorization rule. + :param parameters: The shared access authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates an authorization rule for a queue. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Required. + :type 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: SBAuthorizationRule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: Union[_models.SBAuthorizationRule, IO], + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates an authorization rule for a queue. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRule 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: SBAuthorizationRule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SBAuthorizationRule] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'SBAuthorizationRule') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBAuthorizationRule") request = build_create_or_update_authorization_rule_request( resource_group_name=resource_group_name, @@ -621,18 +705,18 @@ def create_or_update_authorization_rule( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_authorization_rule.metadata['url'], + content=_content, + template_url=self.create_or_update_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -640,15 +724,16 @@ def create_or_update_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}"} # type: ignore - + create_or_update_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}" + } @distributed_trace def delete_authorization_rule( # pylint: disable=inconsistent-return-statements @@ -661,31 +746,35 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements ) -> None: """Deletes a queue authorization rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -693,18 +782,17 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_authorization_rule.metadata['url'], + template_url=self.delete_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -715,8 +803,9 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}"} # type: ignore - + delete_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}" + } @distributed_trace def get_authorization_rule( @@ -729,31 +818,35 @@ def get_authorization_rule( ) -> _models.SBAuthorizationRule: """Gets an authorization rule for a queue by rule name. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.SBAuthorizationRule] = kwargs.pop("cls", None) - request = build_get_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -761,18 +854,17 @@ def get_authorization_rule( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_authorization_rule.metadata['url'], + template_url=self.get_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -780,15 +872,16 @@ def get_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}"} # type: ignore - + get_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}" + } @distributed_trace def list_keys( @@ -801,31 +894,35 @@ def list_keys( ) -> _models.AccessKeys: """Primary and secondary connection strings to the queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.AccessKeys] = kwargs.pop("cls", None) - request = build_list_keys_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -833,18 +930,17 @@ def list_keys( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata['url'], + 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 + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -852,17 +948,18 @@ def list_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + deserialized = self._deserialize("AccessKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/ListKeys"} # type: ignore - + list_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/ListKeys" + } - @distributed_trace + @overload def regenerate_keys( self, resource_group_name: str, @@ -870,39 +967,121 @@ def regenerate_keys( queue_name: str, authorization_rule_name: str, parameters: _models.RegenerateAccessKeyParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.AccessKeys: """Regenerates the primary or secondary connection strings to the queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate the authorization rule. + :param parameters: Parameters supplied to regenerate the authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.RegenerateAccessKeyParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AccessKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AccessKeys: + """Regenerates the primary or secondary connection strings to the queue. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Required. + :type 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: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: Union[_models.RegenerateAccessKeyParameters, IO], + **kwargs: Any + ) -> _models.AccessKeys: + """Regenerates the primary or secondary connection strings to the queue. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Is either a model + type or a IO type. Required. + :type parameters: + ~azure.mgmt.servicebus.v2021_06_01_preview.models.RegenerateAccessKeyParameters 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: AccessKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AccessKeys] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RegenerateAccessKeyParameters") request = build_regenerate_keys_request( resource_group_name=resource_group_name, @@ -913,18 +1092,18 @@ def regenerate_keys( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_keys.metadata['url'], + content=_content, + template_url=self.regenerate_keys.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -932,15 +1111,16 @@ def regenerate_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + deserialized = self._deserialize("AccessKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/regenerateKeys"} # type: ignore - + regenerate_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/regenerateKeys" + } @distributed_trace def list_by_namespace( @@ -950,12 +1130,12 @@ def list_by_namespace( skip: Optional[int] = None, top: Optional[int] = None, **kwargs: Any - ) -> Iterable[_models.SBQueueListResult]: + ) -> Iterable["_models.SBQueue"]: """Gets the queues within a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :param skip: Skip is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skip @@ -965,53 +1145,58 @@ def list_by_namespace( Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBQueueListResult or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBQueueListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either SBQueue or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBQueue] + :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', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBQueueListResult] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.SBQueueListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_namespace_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, - api_version=api_version, skip=skip, top=top, - template_url=self.list_by_namespace.metadata['url'], + api_version=api_version, + template_url=self.list_by_namespace.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_by_namespace_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - skip=skip, - top=top, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -1019,16 +1204,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("SBQueueListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1039,49 +1222,124 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_namespace.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues"} # type: ignore + list_by_namespace.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues" + } - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, namespace_name: str, queue_name: str, parameters: _models.SBQueue, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SBQueue: """Creates or updates a Service Bus queue. This operation is idempotent. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param parameters: Parameters supplied to create or update a queue resource. + :param parameters: Parameters supplied to create or update a queue resource. Required. :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBQueue + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBQueue or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBQueue: + """Creates or updates a Service Bus queue. This operation is idempotent. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param parameters: Parameters supplied to create or update a queue resource. Required. + :type 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: SBQueue, or the result of cls(response) + :return: SBQueue or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBQueue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + parameters: Union[_models.SBQueue, IO], + **kwargs: Any + ) -> _models.SBQueue: + """Creates or updates a Service Bus queue. This operation is idempotent. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param parameters: Parameters supplied to create or update a queue resource. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBQueue 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: SBQueue or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBQueue + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBQueue] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SBQueue] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'SBQueue') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBQueue") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -1091,18 +1349,18 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - 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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1110,67 +1368,67 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBQueue', pipeline_response) + deserialized = self._deserialize("SBQueue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}"} # type: ignore - + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}" + } @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - queue_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, queue_name: str, **kwargs: Any ) -> None: """Deletes a queue from the specified namespace in a resource group. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, queue_name=queue_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1181,60 +1439,58 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}"} # type: ignore - + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}" + } @distributed_trace - def get( - self, - resource_group_name: str, - namespace_name: str, - queue_name: str, - **kwargs: Any - ) -> _models.SBQueue: + def get(self, resource_group_name: str, namespace_name: str, queue_name: str, **kwargs: Any) -> _models.SBQueue: """Returns a description for the specified queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBQueue, or the result of cls(response) + :return: SBQueue or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBQueue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBQueue] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.SBQueue] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, queue_name=queue_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1242,12 +1498,13 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBQueue', pipeline_response) + deserialized = self._deserialize("SBQueue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/operations/_rules_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/operations/_rules_operations.py index c468fa9d4ef7c..87b41000289d3 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/operations/_rules_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/operations/_rules_operations.py @@ -6,11 +6,18 @@ # 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 msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,13 +27,20 @@ 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') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +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_subscriptions_request( resource_group_name: str, namespace_name: str, @@ -41,38 +55,39 @@ def build_list_by_subscriptions_request( _headers = case_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-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, "str", max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if skip is not None: - _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', maximum=1000, minimum=0) + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", maximum=1000, minimum=0) if top is not None: - _params['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", maximum=1000, minimum=1) # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **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( @@ -82,48 +97,44 @@ def build_create_or_update_request( subscription_name: str, rule_name: str, subscription_id: str, - *, - json: Optional[_models.Rule] = None, - content: Any = 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', "2021-06-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: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - "ruleName": _SERIALIZER.url("rule_name", rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, "str", max_length=50, min_length=1), + "ruleName": _SERIALIZER.url("rule_name", rule_name, "str", max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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, - 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( @@ -138,35 +149,36 @@ def build_delete_request( _headers = case_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-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - "ruleName": _SERIALIZER.url("rule_name", rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, "str", max_length=50, min_length=1), + "ruleName": _SERIALIZER.url("rule_name", rule_name, "str", max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( @@ -181,35 +193,37 @@ def build_get_request( _headers = case_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-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - "ruleName": _SERIALIZER.url("rule_name", rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, "str", max_length=50, min_length=1), + "ruleName": _SERIALIZER.url("rule_name", rule_name, "str", max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + class RulesOperations: """ @@ -230,7 +244,6 @@ def __init__(self, *args, **kwargs): 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_subscriptions( self, @@ -241,16 +254,16 @@ def list_by_subscriptions( skip: Optional[int] = None, top: Optional[int] = None, **kwargs: Any - ) -> Iterable[_models.RuleListResult]: + ) -> Iterable["_models.Rule"]: """List all the rules within given topic-subscription. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str :param skip: Skip is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skip @@ -260,57 +273,60 @@ def list_by_subscriptions( Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RuleListResult or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.RuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Rule or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.Rule] + :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', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.RuleListResult] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.RuleListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscriptions_request( resource_group_name=resource_group_name, namespace_name=namespace_name, topic_name=topic_name, subscription_name=subscription_name, subscription_id=self._config.subscription_id, - api_version=api_version, skip=skip, top=top, - template_url=self.list_by_subscriptions.metadata['url'], + api_version=api_version, + template_url=self.list_by_subscriptions.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_by_subscriptions_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - topic_name=topic_name, - subscription_name=subscription_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - skip=skip, - top=top, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -318,16 +334,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("RuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -338,13 +352,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_subscriptions.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules"} # type: ignore + list_by_subscriptions.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules" + } - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, @@ -353,40 +367,127 @@ def create_or_update( subscription_name: str, rule_name: str, parameters: _models.Rule, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.Rule: """Creates a new rule and updates an existing rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str - :param rule_name: The rule name. + :param rule_name: The rule name. Required. :type rule_name: str - :param parameters: Parameters supplied to create a rule. + :param parameters: Parameters supplied to create a rule. Required. :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.Rule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Rule, or the result of cls(response) + :return: Rule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.Rule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Rule: + """Creates a new rule and updates an existing rule. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param rule_name: The rule name. Required. + :type rule_name: str + :param parameters: Parameters supplied to create a rule. Required. + :type 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: Rule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.Rule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + rule_name: str, + parameters: Union[_models.Rule, IO], + **kwargs: Any + ) -> _models.Rule: + """Creates a new rule and updates an existing rule. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param rule_name: The rule name. Required. + :type rule_name: str + :param parameters: Parameters supplied to create a rule. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.Rule 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: Rule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.Rule + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.Rule] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Rule] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'Rule') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Rule") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -398,18 +499,18 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - 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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -417,15 +518,16 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Rule', pipeline_response) + deserialized = self._deserialize("Rule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}"} # type: ignore - + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}" + } @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -439,33 +541,37 @@ def delete( # pylint: disable=inconsistent-return-statements ) -> None: """Deletes an existing rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str - :param rule_name: The rule name. + :param rule_name: The rule name. Required. :type rule_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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -474,18 +580,17 @@ def delete( # pylint: disable=inconsistent-return-statements rule_name=rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -496,8 +601,9 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}"} # type: ignore - + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}" + } @distributed_trace def get( @@ -511,33 +617,37 @@ def get( ) -> _models.Rule: """Retrieves the description for the specified rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str - :param rule_name: The rule name. + :param rule_name: The rule name. Required. :type rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Rule, or the result of cls(response) + :return: Rule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.Rule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Rule] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.Rule] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -546,18 +656,17 @@ def get( rule_name=rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -565,12 +674,13 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Rule', pipeline_response) + deserialized = self._deserialize("Rule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/operations/_subscriptions_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/operations/_subscriptions_operations.py index 239045d04608f..bf19b7fecd808 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/operations/_subscriptions_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/operations/_subscriptions_operations.py @@ -6,11 +6,18 @@ # 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 msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,13 +27,20 @@ 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') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +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_topic_request( resource_group_name: str, namespace_name: str, @@ -40,37 +54,38 @@ def build_list_by_topic_request( _headers = case_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-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if skip is not None: - _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', maximum=1000, minimum=0) + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", maximum=1000, minimum=0) if top is not None: - _params['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", maximum=1000, minimum=1) # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **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( @@ -79,47 +94,43 @@ def build_create_or_update_request( topic_name: str, subscription_name: str, subscription_id: str, - *, - json: Optional[_models.SBSubscription] = None, - content: Any = 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', "2021-06-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: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, "str", max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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, - 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( @@ -133,34 +144,35 @@ def build_delete_request( _headers = case_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-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, "str", max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( @@ -174,34 +186,36 @@ def build_get_request( _headers = case_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-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, "str", max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + class SubscriptionsOperations: """ @@ -222,7 +236,6 @@ def __init__(self, *args, **kwargs): 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_topic( self, @@ -232,14 +245,14 @@ def list_by_topic( skip: Optional[int] = None, top: Optional[int] = None, **kwargs: Any - ) -> Iterable[_models.SBSubscriptionListResult]: + ) -> Iterable["_models.SBSubscription"]: """List all the subscriptions under a specified topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str :param skip: Skip is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skip @@ -249,56 +262,60 @@ def list_by_topic( Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBSubscriptionListResult or the result of - cls(response) + :return: An iterator like instance of either SBSubscription or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBSubscriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBSubscription] + :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', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBSubscriptionListResult] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.SBSubscriptionListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_topic_request( resource_group_name=resource_group_name, namespace_name=namespace_name, topic_name=topic_name, subscription_id=self._config.subscription_id, - api_version=api_version, skip=skip, top=top, - template_url=self.list_by_topic.metadata['url'], + api_version=api_version, + template_url=self.list_by_topic.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_by_topic_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - topic_name=topic_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - skip=skip, - top=top, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -306,16 +323,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("SBSubscriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -326,13 +341,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_topic.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions"} # type: ignore + list_by_topic.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions" + } - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, @@ -340,38 +355,119 @@ def create_or_update( topic_name: str, subscription_name: str, parameters: _models.SBSubscription, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SBSubscription: """Creates a topic subscription. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str - :param parameters: Parameters supplied to create a subscription resource. + :param parameters: Parameters supplied to create a subscription resource. Required. :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBSubscription + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBSubscription or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBSubscription + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBSubscription: + """Creates a topic subscription. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param parameters: Parameters supplied to create a subscription resource. Required. + :type 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: SBSubscription or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBSubscription + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + parameters: Union[_models.SBSubscription, IO], + **kwargs: Any + ) -> _models.SBSubscription: + """Creates a topic subscription. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param parameters: Parameters supplied to create a subscription resource. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBSubscription 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: SBSubscription, or the result of cls(response) + :return: SBSubscription or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBSubscription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBSubscription] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SBSubscription] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'SBSubscription') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBSubscription") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -382,18 +478,18 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - 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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -401,52 +497,52 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBSubscription', pipeline_response) + deserialized = self._deserialize("SBSubscription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}"} # type: ignore - + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}" + } @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - subscription_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, topic_name: str, subscription_name: str, **kwargs: Any ) -> None: """Deletes a subscription from the specified topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -454,18 +550,17 @@ def delete( # pylint: disable=inconsistent-return-statements subscription_name=subscription_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -476,45 +571,45 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}"} # type: ignore - + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}" + } @distributed_trace def get( - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - subscription_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, topic_name: str, subscription_name: str, **kwargs: Any ) -> _models.SBSubscription: """Returns a subscription description for the specified topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBSubscription, or the result of cls(response) + :return: SBSubscription or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBSubscription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBSubscription] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.SBSubscription] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -522,18 +617,17 @@ def get( subscription_name=subscription_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -541,12 +635,13 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBSubscription', pipeline_response) + deserialized = self._deserialize("SBSubscription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/operations/_topics_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/operations/_topics_operations.py index ff59f799cffb1..e5857213afaec 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/operations/_topics_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/operations/_topics_operations.py @@ -6,11 +6,18 @@ # 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 msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,50 +27,54 @@ 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') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_authorization_rules_request( - resource_group_name: str, - namespace_name: str, - topic_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, topic_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-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_authorization_rule_request( @@ -72,47 +83,45 @@ def build_create_or_update_authorization_rule_request( topic_name: str, authorization_rule_name: str, subscription_id: str, - *, - json: Optional[_models.SBAuthorizationRule] = None, - content: Any = 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', "2021-06-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: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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, - 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_get_authorization_rule_request( @@ -126,34 +135,37 @@ def build_get_authorization_rule_request( _headers = case_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-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_authorization_rule_request( @@ -167,34 +179,37 @@ def build_delete_authorization_rule_request( _headers = case_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-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_list_keys_request( @@ -208,34 +223,37 @@ def build_list_keys_request( _headers = case_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-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/ListKeys") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/ListKeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_regenerate_keys_request( @@ -244,47 +262,45 @@ def build_regenerate_keys_request( topic_name: str, authorization_rule_name: str, subscription_id: str, - *, - json: Optional[_models.RegenerateAccessKeyParameters] = None, - content: Any = 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', "2021-06-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: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/regenerateKeys") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/regenerateKeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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, - 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_by_namespace_request( @@ -299,161 +315,149 @@ def build_list_by_namespace_request( _headers = case_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-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if skip is not None: - _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', maximum=1000, minimum=0) + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", maximum=1000, minimum=0) if top is not None: - _params['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", maximum=1000, minimum=1) # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **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( - resource_group_name: str, - namespace_name: str, - topic_name: str, - subscription_id: str, - *, - json: Optional[_models.SBTopic] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_name: str, topic_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-06-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: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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, - 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( - resource_group_name: str, - namespace_name: str, - topic_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, topic_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-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - namespace_name: str, - topic_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, topic_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-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + class TopicsOperations: """ @@ -474,70 +478,71 @@ def __init__(self, *args, **kwargs): 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_authorization_rules( - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - **kwargs: Any - ) -> Iterable[_models.SBAuthorizationRuleListResult]: + self, resource_group_name: str, namespace_name: str, topic_name: str, **kwargs: Any + ) -> Iterable["_models.SBAuthorizationRule"]: """Gets authorization rules for a topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of - cls(response) + :return: An iterator like instance of either SBAuthorizationRule or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRule] + :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', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRuleListResult] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.SBAuthorizationRuleListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_authorization_rules_request( resource_group_name=resource_group_name, namespace_name=namespace_name, topic_name=topic_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_authorization_rules.metadata['url'], + template_url=self.list_authorization_rules.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_authorization_rules_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - topic_name=topic_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -545,16 +550,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("SBAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -565,13 +568,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_authorization_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules"} # type: ignore + list_authorization_rules.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules" + } - @distributed_trace + @overload def create_or_update_authorization_rule( self, resource_group_name: str, @@ -579,38 +582,119 @@ def create_or_update_authorization_rule( topic_name: str, authorization_rule_name: str, parameters: _models.SBAuthorizationRule, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SBAuthorizationRule: """Creates an authorization rule for the specified topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: The shared access authorization rule. + :param parameters: The shared access authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates an authorization rule for the specified topic. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Required. + :type 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: SBAuthorizationRule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: Union[_models.SBAuthorizationRule, IO], + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates an authorization rule for the specified topic. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRule 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: SBAuthorizationRule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SBAuthorizationRule] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'SBAuthorizationRule') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBAuthorizationRule") request = build_create_or_update_authorization_rule_request( resource_group_name=resource_group_name, @@ -621,18 +705,18 @@ def create_or_update_authorization_rule( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_authorization_rule.metadata['url'], + content=_content, + template_url=self.create_or_update_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -640,15 +724,16 @@ def create_or_update_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}"} # type: ignore - + create_or_update_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}" + } @distributed_trace def get_authorization_rule( @@ -661,31 +746,35 @@ def get_authorization_rule( ) -> _models.SBAuthorizationRule: """Returns the specified authorization rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.SBAuthorizationRule] = kwargs.pop("cls", None) - request = build_get_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -693,18 +782,17 @@ def get_authorization_rule( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_authorization_rule.metadata['url'], + template_url=self.get_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -712,15 +800,16 @@ def get_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}"} # type: ignore - + get_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}" + } @distributed_trace def delete_authorization_rule( # pylint: disable=inconsistent-return-statements @@ -733,31 +822,35 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements ) -> None: """Deletes a topic authorization rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -765,18 +858,17 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_authorization_rule.metadata['url'], + template_url=self.delete_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -787,8 +879,9 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}"} # type: ignore - + delete_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}" + } @distributed_trace def list_keys( @@ -801,31 +894,35 @@ def list_keys( ) -> _models.AccessKeys: """Gets the primary and secondary connection strings for the topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.AccessKeys] = kwargs.pop("cls", None) - request = build_list_keys_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -833,18 +930,17 @@ def list_keys( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata['url'], + 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 + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -852,17 +948,18 @@ def list_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + deserialized = self._deserialize("AccessKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/ListKeys"} # type: ignore - + list_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/ListKeys" + } - @distributed_trace + @overload def regenerate_keys( self, resource_group_name: str, @@ -870,39 +967,121 @@ def regenerate_keys( topic_name: str, authorization_rule_name: str, parameters: _models.RegenerateAccessKeyParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.AccessKeys: """Regenerates primary or secondary connection strings for the topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate the authorization rule. + :param parameters: Parameters supplied to regenerate the authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.RegenerateAccessKeyParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AccessKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AccessKeys: + """Regenerates primary or secondary connection strings for the topic. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Required. + :type 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: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: Union[_models.RegenerateAccessKeyParameters, IO], + **kwargs: Any + ) -> _models.AccessKeys: + """Regenerates primary or secondary connection strings for the topic. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Is either a model + type or a IO type. Required. + :type parameters: + ~azure.mgmt.servicebus.v2021_06_01_preview.models.RegenerateAccessKeyParameters 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: AccessKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AccessKeys] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RegenerateAccessKeyParameters") request = build_regenerate_keys_request( resource_group_name=resource_group_name, @@ -913,18 +1092,18 @@ def regenerate_keys( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_keys.metadata['url'], + content=_content, + template_url=self.regenerate_keys.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -932,15 +1111,16 @@ def regenerate_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + deserialized = self._deserialize("AccessKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/regenerateKeys"} # type: ignore - + regenerate_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/regenerateKeys" + } @distributed_trace def list_by_namespace( @@ -950,12 +1130,12 @@ def list_by_namespace( skip: Optional[int] = None, top: Optional[int] = None, **kwargs: Any - ) -> Iterable[_models.SBTopicListResult]: + ) -> Iterable["_models.SBTopic"]: """Gets all the topics in a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :param skip: Skip is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skip @@ -965,53 +1145,58 @@ def list_by_namespace( Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBTopicListResult or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBTopicListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either SBTopic or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBTopic] + :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', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBTopicListResult] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.SBTopicListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_namespace_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, - api_version=api_version, skip=skip, top=top, - template_url=self.list_by_namespace.metadata['url'], + api_version=api_version, + template_url=self.list_by_namespace.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_by_namespace_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - skip=skip, - top=top, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -1019,16 +1204,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("SBTopicListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1039,49 +1222,124 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_namespace.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics"} # type: ignore + list_by_namespace.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics" + } - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, namespace_name: str, topic_name: str, parameters: _models.SBTopic, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SBTopic: """Creates a topic in the specified namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param parameters: Parameters supplied to create a topic resource. + :param parameters: Parameters supplied to create a topic resource. Required. :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBTopic + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBTopic or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBTopic + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBTopic: + """Creates a topic in the specified namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param parameters: Parameters supplied to create a topic resource. Required. + :type 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: SBTopic, or the result of cls(response) + :return: SBTopic or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBTopic - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + parameters: Union[_models.SBTopic, IO], + **kwargs: Any + ) -> _models.SBTopic: + """Creates a topic in the specified namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param parameters: Parameters supplied to create a topic resource. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBTopic 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: SBTopic or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBTopic + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBTopic] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SBTopic] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'SBTopic') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBTopic") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -1091,18 +1349,18 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - 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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1110,67 +1368,67 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBTopic', pipeline_response) + deserialized = self._deserialize("SBTopic", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}"} # type: ignore - + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}" + } @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, topic_name: str, **kwargs: Any ) -> None: """Deletes a topic from the specified namespace and resource group. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, topic_name=topic_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1181,60 +1439,58 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}"} # type: ignore - + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}" + } @distributed_trace - def get( - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - **kwargs: Any - ) -> _models.SBTopic: + def get(self, resource_group_name: str, namespace_name: str, topic_name: str, **kwargs: Any) -> _models.SBTopic: """Returns a description for the specified topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBTopic, or the result of cls(response) + :return: SBTopic or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBTopic - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBTopic] + api_version: Literal["2021-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-06-01-preview") + ) + cls: ClsType[_models.SBTopic] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, topic_name=topic_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1242,12 +1498,13 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBTopic', pipeline_response) + deserialized = self._deserialize("SBTopic", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/__init__.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/__init__.py index 221541a00fb6e..2e171d69863bf 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/__init__.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/__init__.py @@ -13,11 +13,14 @@ try: from ._patch import __all__ as _patch_all - from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import + from ._patch import * # pylint: disable=unused-wildcard-import except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['ServiceBusManagementClient'] + +__all__ = [ + "ServiceBusManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/_configuration.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/_configuration.py index ab694134b4829..fe6357ea43148 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/_configuration.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from ._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential @@ -25,24 +31,19 @@ class ServiceBusManagementClientConfiguration(Configuration): # pylint: disable 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: Subscription credentials that uniquely identify a Microsoft Azure - subscription. The subscription ID forms part of the URI for every service call. + subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2021-11-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(ServiceBusManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", "2021-11-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -52,23 +53,21 @@ def __init__( 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-servicebus/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-servicebus/{}".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') + 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.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/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/_metadata.json b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/_metadata.json index 50b90d8184455..e14908cf405f5 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/_metadata.json +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_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\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ServiceBusManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"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\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ServiceBusManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"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\": [\"ServiceBusManagementClientConfiguration\"], \".._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\": [\"ServiceBusManagementClientConfiguration\"], \"..._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": "Subscription credentials that uniquely identify a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.", + "signature": "subscription_id: str,", + "description": "Subscription credentials that uniquely identify a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. 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": "Subscription credentials that uniquely identify a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.", + "description": "Subscription credentials that uniquely identify a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. Required.", "docstring_type": "str", "required": true } @@ -48,19 +48,19 @@ "service_client_specific": { "sync": { "api_version": { - "signature": "api_version=None, # type: Optional[str]", + "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=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false }, "profile": { - "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "signature": "profile: KnownProfiles=KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", "required": false @@ -108,4 +108,4 @@ "rules": "RulesOperations", "subscriptions": "SubscriptionsOperations" } -} \ No newline at end of file +} diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/_patch.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/_patch.py index 0ad201a8c586e..f7dd32510333d 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/_patch.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/_service_bus_management_client.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/_service_bus_management_client.py index c02b067a6f3b3..cb6df28ce4e30 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/_service_bus_management_client.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/_service_bus_management_client.py @@ -9,20 +9,31 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from . import models +from . import models as _models +from .._serialization import Deserializer, Serializer from ._configuration import ServiceBusManagementClientConfiguration -from .operations import DisasterRecoveryConfigsOperations, MigrationConfigsOperations, NamespacesOperations, Operations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, QueuesOperations, RulesOperations, SubscriptionsOperations, TopicsOperations +from .operations import ( + DisasterRecoveryConfigsOperations, + MigrationConfigsOperations, + NamespacesOperations, + Operations, + PrivateEndpointConnectionsOperations, + PrivateLinkResourcesOperations, + QueuesOperations, + RulesOperations, + SubscriptionsOperations, + TopicsOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class ServiceBusManagementClient: # pylint: disable=too-many-instance-attributes + +class ServiceBusManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Azure Service Bus client for managing Namespace. :ivar namespaces: NamespacesOperations operations @@ -49,10 +60,10 @@ class ServiceBusManagementClient: # pylint: disable=too-many-instance-attribu :vartype rules: azure.mgmt.servicebus.v2021_11_01.operations.RulesOperations :ivar subscriptions: SubscriptionsOperations operations :vartype subscriptions: azure.mgmt.servicebus.v2021_11_01.operations.SubscriptionsOperations - :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: Subscription credentials that uniquely identify a Microsoft Azure - subscription. The subscription ID forms part of the URI for every service call. + subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -70,50 +81,35 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = ServiceBusManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = ServiceBusManagementClientConfiguration( + 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)} + 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.namespaces = NamespacesOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.namespaces = NamespacesOperations(self._client, self._config, self._serialize, self._deserialize) self.private_endpoint_connections = PrivateEndpointConnectionsOperations( self._client, self._config, self._serialize, self._deserialize ) self.private_link_resources = PrivateLinkResourcesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize - ) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) self.disaster_recovery_configs = DisasterRecoveryConfigsOperations( self._client, self._config, self._serialize, self._deserialize ) self.migration_configs = MigrationConfigsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.queues = QueuesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.topics = TopicsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.rules = RulesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.subscriptions = SubscriptionsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - + self.queues = QueuesOperations(self._client, self._config, self._serialize, self._deserialize) + self.topics = TopicsOperations(self._client, self._config, self._serialize, self._deserialize) + self.rules = RulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.subscriptions = SubscriptionsOperations(self._client, self._config, self._serialize, self._deserialize) - def _send_request( - self, - request: 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 @@ -122,7 +118,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 @@ -135,15 +131,12 @@ def _send_request( request_copy.url = self._client.format_url(request_copy.url) return self._client.send_request(request_copy, **kwargs) - def close(self): - # type: () -> None + def close(self) -> None: self._client.close() - def __enter__(self): - # type: () -> ServiceBusManagementClient + def __enter__(self) -> "ServiceBusManagementClient": self._client.__enter__() return self - def __exit__(self, *exc_details): - # type: (Any) -> None + def __exit__(self, *exc_details) -> None: self._client.__exit__(*exc_details) diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/_vendor.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/_vendor.py index 138f663c53a4e..9aad73fc743e7 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/_vendor.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_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/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/_version.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/_version.py index 920456322fa12..e5754a47ce68f 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/_version.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "8.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/__init__.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/__init__.py index e7dd87df1f939..530b8638dfd32 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/__init__.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/__init__.py @@ -10,11 +10,14 @@ try: from ._patch import __all__ as _patch_all - from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import + from ._patch import * # pylint: disable=unused-wildcard-import except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['ServiceBusManagementClient'] + +__all__ = [ + "ServiceBusManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/_configuration.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/_configuration.py index b2b6c2baf5618..094169594ff12 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/_configuration.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from .._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential @@ -25,24 +31,19 @@ class ServiceBusManagementClientConfiguration(Configuration): # pylint: disable 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: Subscription credentials that uniquely identify a Microsoft Azure - subscription. The subscription ID forms part of the URI for every service call. + subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2021-11-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(ServiceBusManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", "2021-11-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -52,22 +53,21 @@ def __init__( 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-servicebus/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-servicebus/{}".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/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/_patch.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/_patch.py index 0ad201a8c586e..f7dd32510333d 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/_patch.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/_service_bus_management_client.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/_service_bus_management_client.py index ec9ebf8c6e76c..ff0b7df82bcee 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/_service_bus_management_client.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/_service_bus_management_client.py @@ -9,20 +9,31 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from .. import models +from .. import models as _models +from ..._serialization import Deserializer, Serializer from ._configuration import ServiceBusManagementClientConfiguration -from .operations import DisasterRecoveryConfigsOperations, MigrationConfigsOperations, NamespacesOperations, Operations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, QueuesOperations, RulesOperations, SubscriptionsOperations, TopicsOperations +from .operations import ( + DisasterRecoveryConfigsOperations, + MigrationConfigsOperations, + NamespacesOperations, + Operations, + PrivateEndpointConnectionsOperations, + PrivateLinkResourcesOperations, + QueuesOperations, + RulesOperations, + SubscriptionsOperations, + TopicsOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class ServiceBusManagementClient: # pylint: disable=too-many-instance-attributes + +class ServiceBusManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Azure Service Bus client for managing Namespace. :ivar namespaces: NamespacesOperations operations @@ -50,10 +61,10 @@ class ServiceBusManagementClient: # pylint: disable=too-many-instance-attribu :ivar subscriptions: SubscriptionsOperations operations :vartype subscriptions: azure.mgmt.servicebus.v2021_11_01.aio.operations.SubscriptionsOperations - :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: Subscription credentials that uniquely identify a Microsoft Azure - subscription. The subscription ID forms part of the URI for every service call. + subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -71,50 +82,35 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = ServiceBusManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = ServiceBusManagementClientConfiguration( + 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)} + 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.namespaces = NamespacesOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.namespaces = NamespacesOperations(self._client, self._config, self._serialize, self._deserialize) self.private_endpoint_connections = PrivateEndpointConnectionsOperations( self._client, self._config, self._serialize, self._deserialize ) self.private_link_resources = PrivateLinkResourcesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize - ) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) self.disaster_recovery_configs = DisasterRecoveryConfigsOperations( self._client, self._config, self._serialize, self._deserialize ) self.migration_configs = MigrationConfigsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.queues = QueuesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.topics = TopicsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.rules = RulesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.subscriptions = SubscriptionsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - + self.queues = QueuesOperations(self._client, self._config, self._serialize, self._deserialize) + self.topics = TopicsOperations(self._client, self._config, self._serialize, self._deserialize) + self.rules = RulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.subscriptions = SubscriptionsOperations(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 @@ -123,7 +119,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/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/operations/__init__.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/operations/__init__.py index 5559ccd3746c6..e5431803c533c 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/operations/__init__.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/operations/__init__.py @@ -18,19 +18,20 @@ from ._subscriptions_operations import SubscriptionsOperations from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'NamespacesOperations', - 'PrivateEndpointConnectionsOperations', - 'PrivateLinkResourcesOperations', - 'Operations', - 'DisasterRecoveryConfigsOperations', - 'MigrationConfigsOperations', - 'QueuesOperations', - 'TopicsOperations', - 'RulesOperations', - 'SubscriptionsOperations', + "NamespacesOperations", + "PrivateEndpointConnectionsOperations", + "PrivateLinkResourcesOperations", + "Operations", + "DisasterRecoveryConfigsOperations", + "MigrationConfigsOperations", + "QueuesOperations", + "TopicsOperations", + "RulesOperations", + "SubscriptionsOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/operations/_disaster_recovery_configs_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/operations/_disaster_recovery_configs_operations.py index 1b72791221cd1..c5378b7b4c9ee 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/operations/_disaster_recovery_configs_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/operations/_disaster_recovery_configs_operations.py @@ -6,10 +6,19 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,27 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._disaster_recovery_configs_operations import build_break_pairing_request, build_check_name_availability_request, build_create_or_update_request, build_delete_request, build_fail_over_request, build_get_authorization_rule_request, build_get_request, build_list_authorization_rules_request, build_list_keys_request, build_list_request -T = TypeVar('T') +from ...operations._disaster_recovery_configs_operations import ( + build_break_pairing_request, + build_check_name_availability_request, + build_create_or_update_request, + build_delete_request, + build_fail_over_request, + build_get_authorization_rule_request, + build_get_request, + build_list_authorization_rules_request, + build_list_keys_request, + build_list_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class DisasterRecoveryConfigsOperations: """ .. warning:: @@ -43,65 +69,66 @@ def __init__(self, *args, **kwargs) -> None: 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, - namespace_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.ArmDisasterRecoveryListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ArmDisasterRecovery"]: """Gets all Alias(Disaster Recovery configurations). - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ArmDisasterRecoveryListResult or the result of - cls(response) + :return: An iterator like instance of either ArmDisasterRecovery or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.ArmDisasterRecoveryListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.ArmDisasterRecovery] + :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', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ArmDisasterRecoveryListResult] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + cls: ClsType[_models.ArmDisasterRecoveryListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -109,16 +136,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("ArmDisasterRecoveryListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -129,49 +154,124 @@ 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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs" + } - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, namespace_name: str, alias: str, parameters: _models.ArmDisasterRecovery, + *, + content_type: str = "application/json", **kwargs: Any ) -> Optional[_models.ArmDisasterRecovery]: """Creates or updates a new Alias(Disaster Recovery configuration). - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: str :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). + Required. :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.ArmDisasterRecovery + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ArmDisasterRecovery or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.ArmDisasterRecovery or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + alias: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> Optional[_models.ArmDisasterRecovery]: + """Creates or updates a new Alias(Disaster Recovery configuration). + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: str + :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). + Required. + :type 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: ArmDisasterRecovery, or the result of cls(response) + :return: ArmDisasterRecovery or None or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.ArmDisasterRecovery or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + alias: str, + parameters: Union[_models.ArmDisasterRecovery, IO], + **kwargs: Any + ) -> Optional[_models.ArmDisasterRecovery]: + """Creates or updates a new Alias(Disaster Recovery configuration). + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: str + :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). Is + either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.ArmDisasterRecovery 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: ArmDisasterRecovery or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.ArmDisasterRecovery or None + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ArmDisasterRecovery]] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.ArmDisasterRecovery]] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'ArmDisasterRecovery') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ArmDisasterRecovery") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -181,18 +281,18 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - 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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -202,67 +302,65 @@ async def create_or_update( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ArmDisasterRecovery', pipeline_response) + deserialized = self._deserialize("ArmDisasterRecovery", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}"} # type: ignore - + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}" + } @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - alias: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, alias: str, **kwargs: Any ) -> None: """Deletes an Alias(Disaster Recovery configuration). - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: 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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, alias=alias, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -273,60 +371,58 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}"} # type: ignore - + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}" + } @distributed_trace_async async def get( - self, - resource_group_name: str, - namespace_name: str, - alias: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, alias: str, **kwargs: Any ) -> _models.ArmDisasterRecovery: """Retrieves Alias(Disaster Recovery configuration) for primary or secondary namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ArmDisasterRecovery, or the result of cls(response) + :return: ArmDisasterRecovery or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.ArmDisasterRecovery - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ArmDisasterRecovery] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + cls: ClsType[_models.ArmDisasterRecovery] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, alias=alias, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -334,68 +430,66 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ArmDisasterRecovery', pipeline_response) + deserialized = self._deserialize("ArmDisasterRecovery", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}" + } @distributed_trace_async async def break_pairing( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - alias: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, alias: str, **kwargs: Any ) -> None: """This operation disables the Disaster Recovery and stops replicating changes from primary to secondary namespaces. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: 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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_break_pairing_request( resource_group_name=resource_group_name, namespace_name=namespace_name, alias=alias, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.break_pairing.metadata['url'], + template_url=self.break_pairing.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -406,50 +500,125 @@ async def break_pairing( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - break_pairing.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/breakPairing"} # type: ignore - + break_pairing.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/breakPairing" + } - @distributed_trace_async + @overload async def fail_over( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, alias: str, parameters: Optional[_models.FailoverProperties] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> None: """Invokes GEO DR failover and reconfigure the alias to point to the secondary namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: str :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). Default value is None. :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.FailoverProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default 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: + """ + + @overload + async def fail_over( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + namespace_name: str, + alias: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Invokes GEO DR failover and reconfigure the alias to point to the secondary namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: str + :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). + Default value is None. + :type 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: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def fail_over( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + namespace_name: str, + alias: str, + parameters: Optional[Union[_models.FailoverProperties, IO]] = None, + **kwargs: Any + ) -> None: + """Invokes GEO DR failover and reconfigure the alias to point to the secondary namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: str + :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). Is + either a model type or a IO type. Default value is None. + :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.FailoverProperties 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: 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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) - if parameters is not None: - _json = self._serialize.body(parameters, 'FailoverProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "FailoverProperties") + else: + _json = None request = build_fail_over_request( resource_group_name=resource_group_name, @@ -459,18 +628,18 @@ async def fail_over( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, json=_json, - template_url=self.fail_over.metadata['url'], + content=_content, + template_url=self.fail_over.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -481,72 +650,73 @@ async def fail_over( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - fail_over.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/failover"} # type: ignore - + fail_over.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/failover" + } @distributed_trace def list_authorization_rules( - self, - resource_group_name: str, - namespace_name: str, - alias: str, - **kwargs: Any - ) -> AsyncIterable[_models.SBAuthorizationRuleListResult]: + self, resource_group_name: str, namespace_name: str, alias: str, **kwargs: Any + ) -> AsyncIterable["_models.SBAuthorizationRule"]: """Gets the authorization rules for a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of - cls(response) + :return: An iterator like instance of either SBAuthorizationRule or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.SBAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.SBAuthorizationRule] + :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', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRuleListResult] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + cls: ClsType[_models.SBAuthorizationRuleListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_authorization_rules_request( resource_group_name=resource_group_name, namespace_name=namespace_name, alias=alias, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_authorization_rules.metadata['url'], + template_url=self.list_authorization_rules.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_authorization_rules_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - alias=alias, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -554,16 +724,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("SBAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -574,48 +742,45 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_authorization_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules"} # type: ignore + list_authorization_rules.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules" + } @distributed_trace_async async def get_authorization_rule( - self, - resource_group_name: str, - namespace_name: str, - alias: str, - authorization_rule_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, alias: str, authorization_rule_name: str, **kwargs: Any ) -> _models.SBAuthorizationRule: """Gets an authorization rule for a namespace by rule name. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + cls: ClsType[_models.SBAuthorizationRule] = kwargs.pop("cls", None) - request = build_get_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -623,18 +788,17 @@ async def get_authorization_rule( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_authorization_rule.metadata['url'], + template_url=self.get_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -642,52 +806,50 @@ async def get_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules/{authorizationRuleName}"} # type: ignore - + get_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules/{authorizationRuleName}" + } @distributed_trace_async async def list_keys( - self, - resource_group_name: str, - namespace_name: str, - alias: str, - authorization_rule_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, alias: str, authorization_rule_name: str, **kwargs: Any ) -> _models.AccessKeys: """Gets the primary and secondary connection strings for the namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + cls: ClsType[_models.AccessKeys] = kwargs.pop("cls", None) - request = build_list_keys_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -695,18 +857,17 @@ async def list_keys( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata['url'], + 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 + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -714,50 +875,118 @@ async def list_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + deserialized = self._deserialize("AccessKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules/{authorizationRuleName}/listKeys"} # type: ignore - + list_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules/{authorizationRuleName}/listKeys" + } - @distributed_trace_async + @overload async def check_name_availability( self, resource_group_name: str, namespace_name: str, parameters: _models.CheckNameAvailability, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Check the give namespace name availability. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: Parameters to check availability of the given namespace name. + :param parameters: Parameters to check availability of the given namespace name. Required. :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.CheckNameAvailability + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckNameAvailabilityResult, or the result of cls(response) + :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.CheckNameAvailabilityResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters to check availability of the given namespace name. Required. + :type 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: CheckNameAvailabilityResult or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_name_availability( + self, + resource_group_name: str, + namespace_name: str, + parameters: Union[_models.CheckNameAvailability, IO], + **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters to check availability of the given namespace name. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.CheckNameAvailability 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: CheckNameAvailabilityResult or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.CheckNameAvailabilityResult] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CheckNameAvailabilityResult] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'CheckNameAvailability') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "CheckNameAvailability") request = build_check_name_availability_request( resource_group_name=resource_group_name, @@ -766,18 +995,18 @@ async def check_name_availability( 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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -785,12 +1014,13 @@ async def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) + deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/CheckNameAvailability"} # type: ignore - + check_name_availability.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/CheckNameAvailability" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/operations/_migration_configs_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/operations/_migration_configs_operations.py index 10db2092c99fb..ba3aa6281f581 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/operations/_migration_configs_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/operations/_migration_configs_operations.py @@ -6,10 +6,19 @@ # 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, Union, cast +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod @@ -22,10 +31,23 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._migration_configs_operations import build_complete_migration_request, build_create_and_start_migration_request_initial, build_delete_request, build_get_request, build_list_request, build_revert_request -T = TypeVar('T') +from ...operations._migration_configs_operations import ( + build_complete_migration_request, + build_create_and_start_migration_request, + build_delete_request, + build_get_request, + build_list_request, + build_revert_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class MigrationConfigsOperations: """ .. warning:: @@ -45,65 +67,67 @@ def __init__(self, *args, **kwargs) -> None: 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, - namespace_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.MigrationConfigListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> AsyncIterable["_models.MigrationConfigProperties"]: """Gets all migrationConfigurations. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MigrationConfigListResult or the result of + :return: An iterator like instance of either MigrationConfigProperties or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.MigrationConfigListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.MigrationConfigProperties] + :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', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MigrationConfigListResult] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + cls: ClsType[_models.MigrationConfigListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -111,16 +135,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("MigrationConfigListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -131,35 +153,44 @@ 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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations" + } async def _create_and_start_migration_initial( self, resource_group_name: str, namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], - parameters: _models.MigrationConfigProperties, + config_name: Union[str, _models.MigrationConfigurationName], + parameters: Union[_models.MigrationConfigProperties, IO], **kwargs: Any ) -> Optional[_models.MigrationConfigProperties]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.MigrationConfigProperties]] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.MigrationConfigProperties]] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'MigrationConfigProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "MigrationConfigProperties") - request = build_create_and_start_migration_request_initial( + request = build_create_and_start_migration_request( resource_group_name=resource_group_name, namespace_name=namespace_name, config_name=config_name, @@ -167,56 +198,142 @@ async def _create_and_start_migration_initial( api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_and_start_migration_initial.metadata['url'], + content=_content, + template_url=self._create_and_start_migration_initial.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('MigrationConfigProperties', pipeline_response) + deserialized = self._deserialize("MigrationConfigProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_and_start_migration_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}"} # type: ignore + _create_and_start_migration_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}" + } - - @distributed_trace_async + @overload async def begin_create_and_start_migration( self, resource_group_name: str, namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], + config_name: Union[str, _models.MigrationConfigurationName], parameters: _models.MigrationConfigProperties, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.MigrationConfigProperties]: """Creates Migration configuration and starts migration of entities from Standard to Premium namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :type config_name: str or ~azure.mgmt.servicebus.v2021_11_01.models.MigrationConfigurationName - :param parameters: Parameters required to create Migration Configuration. + :param parameters: Parameters required to create Migration Configuration. Required. :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.MigrationConfigProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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 MigrationConfigProperties or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.servicebus.v2021_11_01.models.MigrationConfigProperties] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_and_start_migration( + self, + resource_group_name: str, + namespace_name: str, + config_name: Union[str, _models.MigrationConfigurationName], + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.MigrationConfigProperties]: + """Creates Migration configuration and starts migration of entities from Standard to Premium + namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param config_name: The configuration name. Should always be "$default". "$default" Required. + :type config_name: str or ~azure.mgmt.servicebus.v2021_11_01.models.MigrationConfigurationName + :param parameters: Parameters required to create Migration Configuration. Required. + :type 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 + :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 MigrationConfigProperties or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.servicebus.v2021_11_01.models.MigrationConfigProperties] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_and_start_migration( + self, + resource_group_name: str, + namespace_name: str, + config_name: Union[str, _models.MigrationConfigurationName], + parameters: Union[_models.MigrationConfigProperties, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.MigrationConfigProperties]: + """Creates Migration configuration and starts migration of entities from Standard to Premium + namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param config_name: The configuration name. Should always be "$default". "$default" Required. + :type config_name: str or ~azure.mgmt.servicebus.v2021_11_01.models.MigrationConfigurationName + :param parameters: Parameters required to create Migration Configuration. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.MigrationConfigProperties 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 @@ -229,113 +346,109 @@ async def begin_create_and_start_migration( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.servicebus.v2021_11_01.models.MigrationConfigProperties] - :raises: ~azure.core.exceptions.HttpResponseError + :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-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.MigrationConfigProperties] - 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] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.MigrationConfigProperties] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._create_and_start_migration_initial( # type: ignore + raw_result = await self._create_and_start_migration_initial( resource_group_name=resource_group_name, namespace_name=namespace_name, config_name=config_name, parameters=parameters, 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): - deserialized = self._deserialize('MigrationConfigProperties', pipeline_response) + deserialized = self._deserialize("MigrationConfigProperties", 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 + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create_and_start_migration.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}"} # type: ignore + begin_create_and_start_migration.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}" + } @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], + config_name: Union[str, _models.MigrationConfigurationName], **kwargs: Any ) -> None: """Deletes a MigrationConfiguration. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :type config_name: str or ~azure.mgmt.servicebus.v2021_11_01.models.MigrationConfigurationName :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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, config_name=config_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -346,60 +459,62 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}"} # type: ignore - + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}" + } @distributed_trace_async async def get( self, resource_group_name: str, namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], + config_name: Union[str, _models.MigrationConfigurationName], **kwargs: Any ) -> _models.MigrationConfigProperties: """Retrieves Migration Config. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :type config_name: str or ~azure.mgmt.servicebus.v2021_11_01.models.MigrationConfigurationName :keyword callable cls: A custom type or function that will be passed the direct response - :return: MigrationConfigProperties, or the result of cls(response) + :return: MigrationConfigProperties or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.MigrationConfigProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MigrationConfigProperties] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + cls: ClsType[_models.MigrationConfigProperties] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, config_name=config_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -407,69 +522,71 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('MigrationConfigProperties', pipeline_response) + deserialized = self._deserialize("MigrationConfigProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}" + } @distributed_trace_async async def complete_migration( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], + config_name: Union[str, _models.MigrationConfigurationName], **kwargs: Any ) -> None: """This operation Completes Migration of entities by pointing the connection strings to Premium namespace and any entities created after the operation will be under Premium Namespace. CompleteMigration operation will fail when entity migration is in-progress. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :type config_name: str or ~azure.mgmt.servicebus.v2021_11_01.models.MigrationConfigurationName :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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_complete_migration_request( resource_group_name=resource_group_name, namespace_name=namespace_name, config_name=config_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.complete_migration.metadata['url'], + template_url=self.complete_migration.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -480,60 +597,62 @@ async def complete_migration( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - complete_migration.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/upgrade"} # type: ignore - + complete_migration.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/upgrade" + } @distributed_trace_async async def revert( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], + config_name: Union[str, _models.MigrationConfigurationName], **kwargs: Any ) -> None: """This operation reverts Migration. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :type config_name: str or ~azure.mgmt.servicebus.v2021_11_01.models.MigrationConfigurationName :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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_revert_request( resource_group_name=resource_group_name, namespace_name=namespace_name, config_name=config_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.revert.metadata['url'], + template_url=self.revert.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -544,5 +663,6 @@ async def revert( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - revert.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/revert"} # type: ignore - + revert.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/revert" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/operations/_namespaces_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/operations/_namespaces_operations.py index e506111068123..7ead624568d57 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/operations/_namespaces_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/operations/_namespaces_operations.py @@ -6,10 +6,19 @@ # 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, Union, cast +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod @@ -22,10 +31,33 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._namespaces_operations import build_check_name_availability_request, build_create_or_update_authorization_rule_request, build_create_or_update_network_rule_set_request, build_create_or_update_request_initial, build_delete_authorization_rule_request, build_delete_request_initial, build_get_authorization_rule_request, build_get_network_rule_set_request, build_get_request, build_list_authorization_rules_request, build_list_by_resource_group_request, build_list_keys_request, build_list_network_rule_sets_request, build_list_request, build_regenerate_keys_request, build_update_request -T = TypeVar('T') +from ...operations._namespaces_operations import ( + build_check_name_availability_request, + build_create_or_update_authorization_rule_request, + build_create_or_update_network_rule_set_request, + build_create_or_update_request, + build_delete_authorization_rule_request, + build_delete_request, + build_get_authorization_rule_request, + build_get_network_rule_set_request, + build_get_request, + build_list_authorization_rules_request, + build_list_by_resource_group_request, + build_list_keys_request, + build_list_network_rule_sets_request, + build_list_request, + build_regenerate_keys_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class NamespacesOperations: """ .. warning:: @@ -45,55 +77,58 @@ def __init__(self, *args, **kwargs) -> None: 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.SBNamespaceListResult]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.SBNamespace"]: """Gets all the available namespaces within the subscription, irrespective of the resource groups. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBNamespaceListResult or the result of - cls(response) + :return: An iterator like instance of either SBNamespace or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.SBNamespaceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.SBNamespace] + :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', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBNamespaceListResult] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + cls: ClsType[_models.SBNamespaceListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -101,16 +136,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("SBNamespaceListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -121,65 +154,65 @@ 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': "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/namespaces"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/namespaces"} @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.SBNamespaceListResult]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.SBNamespace"]: """Gets the available namespaces within a resource group. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. 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 SBNamespaceListResult or the result of - cls(response) + :return: An iterator like instance of either SBNamespace or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.SBNamespaceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.SBNamespace] + :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', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBNamespaceListResult] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + cls: ClsType[_models.SBNamespaceListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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'], + 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 + request.url = self._client.format_url(request.url) else: - - 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=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -187,16 +220,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("SBNamespaceListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -207,90 +238,171 @@ 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.ServiceBus/namespaces"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces" + } async def _create_or_update_initial( - self, - resource_group_name: str, - namespace_name: str, - parameters: _models.SBNamespace, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, parameters: Union[_models.SBNamespace, IO], **kwargs: Any ) -> Optional[_models.SBNamespace]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.SBNamespace]] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.SBNamespace]] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'SBNamespace') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBNamespace") - request = build_create_or_update_request_initial( + request = build_create_or_update_request( resource_group_name=resource_group_name, namespace_name=namespace_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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('SBNamespace', pipeline_response) + deserialized = self._deserialize("SBNamespace", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('SBNamespace', pipeline_response) + deserialized = self._deserialize("SBNamespace", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore - + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}" + } - @distributed_trace_async + @overload async def begin_create_or_update( self, resource_group_name: str, namespace_name: str, parameters: _models.SBNamespace, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.SBNamespace]: """Creates or updates a service namespace. Once created, this namespace's resource manifest is immutable. This operation is idempotent. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: Parameters supplied to create a namespace resource. + :param parameters: Parameters supplied to create a namespace resource. Required. :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.SBNamespace + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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 SBNamespace or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.servicebus.v2021_11_01.models.SBNamespace] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.SBNamespace]: + """Creates or updates a service namespace. Once created, this namespace's resource manifest is + immutable. This operation is idempotent. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to create a namespace resource. Required. + :type 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 + :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 SBNamespace or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.servicebus.v2021_11_01.models.SBNamespace] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, resource_group_name: str, namespace_name: str, parameters: Union[_models.SBNamespace, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.SBNamespace]: + """Creates or updates a service namespace. Once created, this namespace's resource manifest is + immutable. This operation is idempotent. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to create a namespace resource. Is either a model type + or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.SBNamespace 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 @@ -303,121 +415,111 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.servicebus.v2021_11_01.models.SBNamespace] - :raises: ~azure.core.exceptions.HttpResponseError + :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-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBNamespace] - 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] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SBNamespace] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._create_or_update_initial( # type: ignore + raw_result = await self._create_or_update_initial( resource_group_name=resource_group_name, namespace_name=namespace_name, parameters=parameters, 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): - deserialized = self._deserialize('SBNamespace', pipeline_response) + deserialized = self._deserialize("SBNamespace", 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 + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, **kwargs: Any ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request_initial( + request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + 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 + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}" + } @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete(self, resource_group_name: str, namespace_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes an existing namespace. This operation also removes all associated resources under the namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_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. @@ -429,103 +531,94 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements 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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: 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] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, namespace_name=namespace_name, api_version=api_version, - 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 = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}" + } @distributed_trace_async - async def get( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> _models.SBNamespace: + async def get(self, resource_group_name: str, namespace_name: str, **kwargs: Any) -> _models.SBNamespace: """Gets a description for the specified namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBNamespace, or the result of cls(response) + :return: SBNamespace or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.SBNamespace - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBNamespace] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + cls: ClsType[_models.SBNamespace] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -533,51 +626,121 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBNamespace', pipeline_response) + deserialized = self._deserialize("SBNamespace", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}" + } - @distributed_trace_async + @overload async def update( self, resource_group_name: str, namespace_name: str, parameters: _models.SBNamespaceUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> Optional[_models.SBNamespace]: """Updates a service namespace. Once created, this namespace's resource manifest is immutable. This operation is idempotent. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: Parameters supplied to update a namespace resource. + :param parameters: Parameters supplied to update a namespace resource. Required. :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.SBNamespaceUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBNamespace, or the result of cls(response) + :return: SBNamespace or None or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.SBNamespace or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> Optional[_models.SBNamespace]: + """Updates a service namespace. Once created, this namespace's resource manifest is immutable. + This operation is idempotent. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to update a namespace resource. Required. + :type 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: SBNamespace or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.SBNamespace or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + namespace_name: str, + parameters: Union[_models.SBNamespaceUpdateParameters, IO], + **kwargs: Any + ) -> Optional[_models.SBNamespace]: + """Updates a service namespace. Once created, this namespace's resource manifest is immutable. + This operation is idempotent. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to update a namespace resource. Is either a model type + or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.SBNamespaceUpdateParameters 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: SBNamespace or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.SBNamespace or None + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.SBNamespace]] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.SBNamespace]] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'SBNamespaceUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBNamespaceUpdateParameters") request = build_update_request( resource_group_name=resource_group_name, @@ -586,18 +749,18 @@ async def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -607,53 +770,120 @@ async def update( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('SBNamespace', pipeline_response) + deserialized = self._deserialize("SBNamespace", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('SBNamespace', pipeline_response) + deserialized = self._deserialize("SBNamespace", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore - + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}" + } - @distributed_trace_async + @overload async def create_or_update_network_rule_set( self, resource_group_name: str, namespace_name: str, parameters: _models.NetworkRuleSet, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.NetworkRuleSet: """Create or update NetworkRuleSet for a Namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: The Namespace IpFilterRule. + :param parameters: The Namespace IpFilterRule. Required. :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.NetworkRuleSet + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: NetworkRuleSet or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.NetworkRuleSet + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_network_rule_set( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.NetworkRuleSet: + """Create or update NetworkRuleSet for a Namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: The Namespace IpFilterRule. Required. + :type 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: NetworkRuleSet, or the result of cls(response) + :return: NetworkRuleSet or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.NetworkRuleSet - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update_network_rule_set( + self, + resource_group_name: str, + namespace_name: str, + parameters: Union[_models.NetworkRuleSet, IO], + **kwargs: Any + ) -> _models.NetworkRuleSet: + """Create or update NetworkRuleSet for a Namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: The Namespace IpFilterRule. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.NetworkRuleSet 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: NetworkRuleSet or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.NetworkRuleSet + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.NetworkRuleSet] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.NetworkRuleSet] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'NetworkRuleSet') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "NetworkRuleSet") request = build_create_or_update_network_rule_set_request( resource_group_name=resource_group_name, @@ -662,18 +892,18 @@ async def create_or_update_network_rule_set( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_network_rule_set.metadata['url'], + content=_content, + template_url=self.create_or_update_network_rule_set.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -681,63 +911,62 @@ async def create_or_update_network_rule_set( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('NetworkRuleSet', pipeline_response) + deserialized = self._deserialize("NetworkRuleSet", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_network_rule_set.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default"} # type: ignore - + create_or_update_network_rule_set.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default" + } @distributed_trace_async async def get_network_rule_set( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, **kwargs: Any ) -> _models.NetworkRuleSet: """Gets NetworkRuleSet for a Namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: NetworkRuleSet, or the result of cls(response) + :return: NetworkRuleSet or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.NetworkRuleSet - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.NetworkRuleSet] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + cls: ClsType[_models.NetworkRuleSet] = kwargs.pop("cls", None) - request = build_get_network_rule_set_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_network_rule_set.metadata['url'], + template_url=self.get_network_rule_set.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -745,74 +974,77 @@ async def get_network_rule_set( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('NetworkRuleSet', pipeline_response) + deserialized = self._deserialize("NetworkRuleSet", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_network_rule_set.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default"} # type: ignore - + get_network_rule_set.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default" + } @distributed_trace def list_network_rule_sets( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.NetworkRuleSetListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> AsyncIterable["_models.NetworkRuleSet"]: """Gets list of NetworkRuleSet for a Namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either NetworkRuleSetListResult or the result of - cls(response) + :return: An iterator like instance of either NetworkRuleSet or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.NetworkRuleSetListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.NetworkRuleSet] + :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', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.NetworkRuleSetListResult] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + cls: ClsType[_models.NetworkRuleSetListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_network_rule_sets_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_network_rule_sets.metadata['url'], + template_url=self.list_network_rule_sets.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_network_rule_sets_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -820,16 +1052,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("NetworkRuleSetListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -840,70 +1070,72 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_network_rule_sets.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets"} # type: ignore + list_network_rule_sets.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets" + } @distributed_trace def list_authorization_rules( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.SBAuthorizationRuleListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> AsyncIterable["_models.SBAuthorizationRule"]: """Gets the authorization rules for a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of - cls(response) + :return: An iterator like instance of either SBAuthorizationRule or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.SBAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.SBAuthorizationRule] + :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', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRuleListResult] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + cls: ClsType[_models.SBAuthorizationRuleListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_authorization_rules_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_authorization_rules.metadata['url'], + template_url=self.list_authorization_rules.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_authorization_rules_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -911,16 +1143,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("SBAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -931,49 +1161,122 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_authorization_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules"} # type: ignore + list_authorization_rules.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules" + } - @distributed_trace_async + @overload async def create_or_update_authorization_rule( self, resource_group_name: str, namespace_name: str, authorization_rule_name: str, parameters: _models.SBAuthorizationRule, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SBAuthorizationRule: """Creates or updates an authorization rule for a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: The shared access authorization rule. + :param parameters: The shared access authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.SBAuthorizationRule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates or updates an authorization rule for a namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Required. + :type 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: SBAuthorizationRule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: Union[_models.SBAuthorizationRule, IO], + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates or updates an authorization rule for a namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.SBAuthorizationRule 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: SBAuthorizationRule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SBAuthorizationRule] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'SBAuthorizationRule') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBAuthorizationRule") request = build_create_or_update_authorization_rule_request( resource_group_name=resource_group_name, @@ -983,18 +1286,18 @@ async def create_or_update_authorization_rule( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_authorization_rule.metadata['url'], + content=_content, + template_url=self.create_or_update_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1002,67 +1305,65 @@ async def create_or_update_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}"} # type: ignore - + create_or_update_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}" + } @distributed_trace_async async def delete_authorization_rule( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, authorization_rule_name: str, **kwargs: Any ) -> None: """Deletes a namespace authorization rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_authorization_rule.metadata['url'], + template_url=self.delete_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1073,60 +1374,58 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat if cls: return cls(pipeline_response, None, {}) - delete_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}"} # type: ignore - + delete_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}" + } @distributed_trace_async async def get_authorization_rule( - self, - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, authorization_rule_name: str, **kwargs: Any ) -> _models.SBAuthorizationRule: """Gets an authorization rule for a namespace by rule name. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + cls: ClsType[_models.SBAuthorizationRule] = kwargs.pop("cls", None) - request = build_get_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_authorization_rule.metadata['url'], + template_url=self.get_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1134,67 +1433,65 @@ async def get_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}"} # type: ignore - + get_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}" + } @distributed_trace_async async def list_keys( - self, - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, authorization_rule_name: str, **kwargs: Any ) -> _models.AccessKeys: """Gets the primary and secondary connection strings for the namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + cls: ClsType[_models.AccessKeys] = kwargs.pop("cls", None) - request = build_list_keys_request( resource_group_name=resource_group_name, namespace_name=namespace_name, authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata['url'], + 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 + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1202,53 +1499,127 @@ async def list_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + deserialized = self._deserialize("AccessKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/listKeys"} # type: ignore - + list_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/listKeys" + } - @distributed_trace_async + @overload async def regenerate_keys( self, resource_group_name: str, namespace_name: str, authorization_rule_name: str, parameters: _models.RegenerateAccessKeyParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.AccessKeys: """Regenerates the primary or secondary connection strings for the namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate the authorization rule. + :param parameters: Parameters supplied to regenerate the authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.RegenerateAccessKeyParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AccessKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AccessKeys: + """Regenerates the primary or secondary connection strings for the namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Required. + :type 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: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: Union[_models.RegenerateAccessKeyParameters, IO], + **kwargs: Any + ) -> _models.AccessKeys: + """Regenerates the primary or secondary connection strings for the namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.RegenerateAccessKeyParameters 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: AccessKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AccessKeys] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RegenerateAccessKeyParameters") request = build_regenerate_keys_request( resource_group_name=resource_group_name, @@ -1258,18 +1629,18 @@ async def regenerate_keys( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_keys.metadata['url'], + content=_content, + template_url=self.regenerate_keys.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1277,62 +1648,108 @@ async def regenerate_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + deserialized = self._deserialize("AccessKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/regenerateKeys"} # type: ignore + regenerate_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/regenerateKeys" + } + @overload + async def check_name_availability( + self, parameters: _models.CheckNameAvailability, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param parameters: Parameters to check availability of the given namespace name. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.CheckNameAvailability + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckNameAvailabilityResult or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param parameters: Parameters to check availability of the given namespace name. Required. + :type 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: CheckNameAvailabilityResult or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def check_name_availability( - self, - parameters: _models.CheckNameAvailability, - **kwargs: Any + self, parameters: Union[_models.CheckNameAvailability, IO], **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Check the give namespace name availability. - :param parameters: Parameters to check availability of the given namespace name. - :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.CheckNameAvailability + :param parameters: Parameters to check availability of the given namespace name. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.CheckNameAvailability 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: CheckNameAvailabilityResult, or the result of cls(response) + :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.CheckNameAvailabilityResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.CheckNameAvailabilityResult] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CheckNameAvailabilityResult] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'CheckNameAvailability') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "CheckNameAvailability") 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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1340,12 +1757,13 @@ async def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) + deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/CheckNameAvailability"} # type: ignore - + check_name_availability.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/CheckNameAvailability" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/operations/_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/operations/_operations.py index fdc33b7967a66..b9e1b3d10492f 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/operations/_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/operations/_operations.py @@ -6,10 +6,19 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +29,15 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._operations import build_list_request -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class Operations: """ .. warning:: @@ -42,52 +57,57 @@ def __init__(self, *args, **kwargs) -> None: 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 ServiceBus 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.servicebus.v2021_11_01.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_11_01.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', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_request( - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -95,16 +115,14 @@ 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) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -115,8 +133,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.ServiceBus/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.ServiceBus/operations"} diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/operations/_patch.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/operations/_patch.py index 0ad201a8c586e..f7dd32510333d 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/operations/_patch.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/operations/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/operations/_private_endpoint_connections_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/operations/_private_endpoint_connections_operations.py index df8a2914a8d23..7c3f7017f5e05 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/operations/_private_endpoint_connections_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/operations/_private_endpoint_connections_operations.py @@ -6,10 +6,19 @@ # 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, Union, cast +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod @@ -22,10 +31,21 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._private_endpoint_connections_operations import build_create_or_update_request, build_delete_request_initial, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._private_endpoint_connections_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class PrivateEndpointConnectionsOperations: """ .. warning:: @@ -45,65 +65,67 @@ def __init__(self, *args, **kwargs) -> None: 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, - namespace_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.PrivateEndpointConnectionListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> AsyncIterable["_models.PrivateEndpointConnection"]: """Gets the available PrivateEndpointConnections within a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateEndpointConnectionListResult or the result - of cls(response) + :return: An iterator like instance of either PrivateEndpointConnection or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.PrivateEndpointConnectionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_11_01.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', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnectionListResult] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -111,16 +133,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -131,71 +151,145 @@ 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': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections" + } - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, namespace_name: str, private_endpoint_connection_name: str, parameters: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.PrivateEndpointConnection: """Creates or updates PrivateEndpointConnections of service namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param private_endpoint_connection_name: The PrivateEndpointConnection name. + :param private_endpoint_connection_name: The PrivateEndpointConnection name. Required. :type private_endpoint_connection_name: str :param parameters: Parameters supplied to update Status of PrivateEndPoint Connection to - namespace resource. + namespace resource. Required. :type parameters: ~azure.mgmt.servicebus.v2021_11_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 + :return: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + private_endpoint_connection_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Creates or updates PrivateEndpointConnections of service namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param private_endpoint_connection_name: The PrivateEndpointConnection name. Required. + :type private_endpoint_connection_name: str + :param parameters: Parameters supplied to update Status of PrivateEndPoint Connection to + namespace resource. Required. + :type 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: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + private_endpoint_connection_name: str, + parameters: Union[_models.PrivateEndpointConnection, IO], + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Creates or updates PrivateEndpointConnections of service namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param private_endpoint_connection_name: The PrivateEndpointConnection name. Required. + :type private_endpoint_connection_name: str + :param parameters: Parameters supplied to update Status of PrivateEndPoint Connection to + namespace resource. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_11_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 - :return: PrivateEndpointConnection, or the result of cls(response) + :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'PrivateEndpointConnection') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PrivateEndpointConnection") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, namespace_name=namespace_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.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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -204,86 +298,82 @@ async def create_or_update( 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 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 + return cls(pipeline_response, deserialized, {}) # type: ignore - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + return deserialized # type: ignore + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request_initial( + request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, - subscription_id=self._config.subscription_id, 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'], + 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 + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}" + } @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, namespace_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes an existing Private Endpoint Connection. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param private_endpoint_connection_name: The PrivateEndpointConnection name. + :param private_endpoint_connection_name: The PrivateEndpointConnection name. 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. @@ -295,108 +385,100 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements 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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: 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] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, namespace_name=namespace_name, private_endpoint_connection_name=private_endpoint_connection_name, api_version=api_version, - 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 = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}" + } @distributed_trace_async async def get( - self, - resource_group_name: str, - namespace_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> _models.PrivateEndpointConnection: """Gets a description for the specified Private Endpoint Connection. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param private_endpoint_connection_name: The PrivateEndpointConnection name. + :param private_endpoint_connection_name: The PrivateEndpointConnection name. 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.servicebus.v2021_11_01.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_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'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -404,12 +486,13 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, 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.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/operations/_private_link_resources_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/operations/_private_link_resources_operations.py index ad4b657278b9a..041928d0b74af 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/operations/_private_link_resources_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/operations/_private_link_resources_operations.py @@ -6,9 +6,17 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Optional, TypeVar -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -19,9 +27,15 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._private_link_resources_operations import build_get_request -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class PrivateLinkResourcesOperations: """ .. warning:: @@ -41,54 +55,51 @@ def __init__(self, *args, **kwargs) -> None: 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, - namespace_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, **kwargs: Any ) -> _models.PrivateLinkResourcesListResult: """Gets lists of resources that supports Privatelinks. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateLinkResourcesListResult, or the result of cls(response) + :return: PrivateLinkResourcesListResult or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.PrivateLinkResourcesListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateLinkResourcesListResult] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + cls: ClsType[_models.PrivateLinkResourcesListResult] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -96,12 +107,13 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateLinkResourcesListResult', pipeline_response) + deserialized = self._deserialize("PrivateLinkResourcesListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateLinkResources"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateLinkResources" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/operations/_queues_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/operations/_queues_operations.py index 483fd0d85122b..af567f9898b4c 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/operations/_queues_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/operations/_queues_operations.py @@ -6,10 +6,19 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,27 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._queues_operations import build_create_or_update_authorization_rule_request, build_create_or_update_request, build_delete_authorization_rule_request, build_delete_request, build_get_authorization_rule_request, build_get_request, build_list_authorization_rules_request, build_list_by_namespace_request, build_list_keys_request, build_regenerate_keys_request -T = TypeVar('T') +from ...operations._queues_operations import ( + build_create_or_update_authorization_rule_request, + build_create_or_update_request, + build_delete_authorization_rule_request, + build_delete_request, + build_get_authorization_rule_request, + build_get_request, + build_list_authorization_rules_request, + build_list_by_namespace_request, + build_list_keys_request, + build_regenerate_keys_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class QueuesOperations: """ .. warning:: @@ -43,70 +69,69 @@ def __init__(self, *args, **kwargs) -> None: 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_authorization_rules( - self, - resource_group_name: str, - namespace_name: str, - queue_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.SBAuthorizationRuleListResult]: + self, resource_group_name: str, namespace_name: str, queue_name: str, **kwargs: Any + ) -> AsyncIterable["_models.SBAuthorizationRule"]: """Gets all authorization rules for a queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of - cls(response) + :return: An iterator like instance of either SBAuthorizationRule or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.SBAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.SBAuthorizationRule] + :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', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRuleListResult] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + cls: ClsType[_models.SBAuthorizationRuleListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_authorization_rules_request( resource_group_name=resource_group_name, namespace_name=namespace_name, queue_name=queue_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_authorization_rules.metadata['url'], + template_url=self.list_authorization_rules.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_authorization_rules_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - queue_name=queue_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -114,16 +139,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("SBAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -134,13 +157,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_authorization_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules"} # type: ignore + list_authorization_rules.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules" + } - @distributed_trace_async + @overload async def create_or_update_authorization_rule( self, resource_group_name: str, @@ -148,38 +171,117 @@ async def create_or_update_authorization_rule( queue_name: str, authorization_rule_name: str, parameters: _models.SBAuthorizationRule, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SBAuthorizationRule: """Creates an authorization rule for a queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: The shared access authorization rule. + :param parameters: The shared access authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.SBAuthorizationRule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBAuthorizationRule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates an authorization rule for a queue. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Required. + :type 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: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: Union[_models.SBAuthorizationRule, IO], + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates an authorization rule for a queue. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.SBAuthorizationRule 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: SBAuthorizationRule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SBAuthorizationRule] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'SBAuthorizationRule') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBAuthorizationRule") request = build_create_or_update_authorization_rule_request( resource_group_name=resource_group_name, @@ -190,18 +292,18 @@ async def create_or_update_authorization_rule( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_authorization_rule.metadata['url'], + content=_content, + template_url=self.create_or_update_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -209,15 +311,16 @@ async def create_or_update_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}"} # type: ignore - + create_or_update_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}" + } @distributed_trace_async async def delete_authorization_rule( # pylint: disable=inconsistent-return-statements @@ -230,31 +333,33 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat ) -> None: """Deletes a queue authorization rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -262,18 +367,17 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_authorization_rule.metadata['url'], + template_url=self.delete_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -284,8 +388,9 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat if cls: return cls(pipeline_response, None, {}) - delete_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}"} # type: ignore - + delete_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}" + } @distributed_trace_async async def get_authorization_rule( @@ -298,31 +403,33 @@ async def get_authorization_rule( ) -> _models.SBAuthorizationRule: """Gets an authorization rule for a queue by rule name. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + cls: ClsType[_models.SBAuthorizationRule] = kwargs.pop("cls", None) - request = build_get_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -330,18 +437,17 @@ async def get_authorization_rule( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_authorization_rule.metadata['url'], + template_url=self.get_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -349,15 +455,16 @@ async def get_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}"} # type: ignore - + get_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}" + } @distributed_trace_async async def list_keys( @@ -370,31 +477,33 @@ async def list_keys( ) -> _models.AccessKeys: """Primary and secondary connection strings to the queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + cls: ClsType[_models.AccessKeys] = kwargs.pop("cls", None) - request = build_list_keys_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -402,18 +511,17 @@ async def list_keys( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata['url'], + 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 + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -421,17 +529,18 @@ async def list_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + deserialized = self._deserialize("AccessKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/ListKeys"} # type: ignore - + list_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/ListKeys" + } - @distributed_trace_async + @overload async def regenerate_keys( self, resource_group_name: str, @@ -439,38 +548,117 @@ async def regenerate_keys( queue_name: str, authorization_rule_name: str, parameters: _models.RegenerateAccessKeyParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.AccessKeys: """Regenerates the primary or secondary connection strings to the queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate the authorization rule. + :param parameters: Parameters supplied to regenerate the authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.RegenerateAccessKeyParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AccessKeys: + """Regenerates the primary or secondary connection strings to the queue. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Required. + :type 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: AccessKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: Union[_models.RegenerateAccessKeyParameters, IO], + **kwargs: Any + ) -> _models.AccessKeys: + """Regenerates the primary or secondary connection strings to the queue. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.RegenerateAccessKeyParameters 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: AccessKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AccessKeys] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RegenerateAccessKeyParameters") request = build_regenerate_keys_request( resource_group_name=resource_group_name, @@ -481,18 +669,18 @@ async def regenerate_keys( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_keys.metadata['url'], + content=_content, + template_url=self.regenerate_keys.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -500,15 +688,16 @@ async def regenerate_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + deserialized = self._deserialize("AccessKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/regenerateKeys"} # type: ignore - + regenerate_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/regenerateKeys" + } @distributed_trace def list_by_namespace( @@ -518,12 +707,12 @@ def list_by_namespace( skip: Optional[int] = None, top: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable[_models.SBQueueListResult]: + ) -> AsyncIterable["_models.SBQueue"]: """Gets the queues within a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :param skip: Skip is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skip @@ -533,53 +722,57 @@ def list_by_namespace( Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBQueueListResult or the result of cls(response) + :return: An iterator like instance of either SBQueue or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.SBQueueListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.SBQueue] + :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', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBQueueListResult] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + cls: ClsType[_models.SBQueueListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_namespace_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, - api_version=api_version, skip=skip, top=top, - template_url=self.list_by_namespace.metadata['url'], + api_version=api_version, + template_url=self.list_by_namespace.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_by_namespace_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - skip=skip, - top=top, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -587,16 +780,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("SBQueueListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -607,49 +798,122 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_namespace.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues"} # type: ignore + list_by_namespace.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues" + } - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, namespace_name: str, queue_name: str, parameters: _models.SBQueue, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SBQueue: """Creates or updates a Service Bus queue. This operation is idempotent. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param parameters: Parameters supplied to create or update a queue resource. + :param parameters: Parameters supplied to create or update a queue resource. Required. :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.SBQueue + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBQueue or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.SBQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBQueue: + """Creates or updates a Service Bus queue. This operation is idempotent. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param parameters: Parameters supplied to create or update a queue resource. Required. + :type 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: SBQueue, or the result of cls(response) + :return: SBQueue or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.SBQueue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + parameters: Union[_models.SBQueue, IO], + **kwargs: Any + ) -> _models.SBQueue: + """Creates or updates a Service Bus queue. This operation is idempotent. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param parameters: Parameters supplied to create or update a queue resource. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.SBQueue 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: SBQueue or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.SBQueue + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBQueue] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SBQueue] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'SBQueue') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBQueue") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -659,18 +923,18 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - 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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -678,67 +942,65 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBQueue', pipeline_response) + deserialized = self._deserialize("SBQueue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}"} # type: ignore - + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}" + } @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - queue_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, queue_name: str, **kwargs: Any ) -> None: """Deletes a queue from the specified namespace in a resource group. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, queue_name=queue_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -749,60 +1011,58 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}"} # type: ignore - + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}" + } @distributed_trace_async async def get( - self, - resource_group_name: str, - namespace_name: str, - queue_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, queue_name: str, **kwargs: Any ) -> _models.SBQueue: """Returns a description for the specified queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBQueue, or the result of cls(response) + :return: SBQueue or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.SBQueue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBQueue] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + cls: ClsType[_models.SBQueue] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, queue_name=queue_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -810,12 +1070,13 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBQueue', pipeline_response) + deserialized = self._deserialize("SBQueue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/operations/_rules_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/operations/_rules_operations.py index a0a5ee36616d4..91c7dbf95f3b0 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/operations/_rules_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/operations/_rules_operations.py @@ -6,10 +6,19 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,21 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._rules_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_by_subscriptions_request -T = TypeVar('T') +from ...operations._rules_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_subscriptions_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class RulesOperations: """ .. warning:: @@ -43,7 +63,6 @@ def __init__(self, *args, **kwargs) -> None: 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_subscriptions( self, @@ -54,16 +73,16 @@ def list_by_subscriptions( skip: Optional[int] = None, top: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable[_models.RuleListResult]: + ) -> AsyncIterable["_models.Rule"]: """List all the rules within given topic-subscription. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str :param skip: Skip is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skip @@ -73,57 +92,58 @@ def list_by_subscriptions( Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RuleListResult or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.RuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Rule or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.Rule] + :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', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.RuleListResult] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + cls: ClsType[_models.RuleListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscriptions_request( resource_group_name=resource_group_name, namespace_name=namespace_name, topic_name=topic_name, subscription_name=subscription_name, subscription_id=self._config.subscription_id, - api_version=api_version, skip=skip, top=top, - template_url=self.list_by_subscriptions.metadata['url'], + api_version=api_version, + template_url=self.list_by_subscriptions.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_by_subscriptions_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - topic_name=topic_name, - subscription_name=subscription_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - skip=skip, - top=top, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -131,16 +151,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("RuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -151,13 +169,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_subscriptions.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules"} # type: ignore + list_by_subscriptions.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules" + } - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, @@ -166,40 +184,125 @@ async def create_or_update( subscription_name: str, rule_name: str, parameters: _models.Rule, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.Rule: """Creates a new rule and updates an existing rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str - :param rule_name: The rule name. + :param rule_name: The rule name. Required. :type rule_name: str - :param parameters: Parameters supplied to create a rule. + :param parameters: Parameters supplied to create a rule. Required. :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.Rule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Rule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.Rule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Rule: + """Creates a new rule and updates an existing rule. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param rule_name: The rule name. Required. + :type rule_name: str + :param parameters: Parameters supplied to create a rule. Required. + :type 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: Rule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.Rule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + rule_name: str, + parameters: Union[_models.Rule, IO], + **kwargs: Any + ) -> _models.Rule: + """Creates a new rule and updates an existing rule. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param rule_name: The rule name. Required. + :type rule_name: str + :param parameters: Parameters supplied to create a rule. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.Rule 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: Rule, or the result of cls(response) + :return: Rule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.Rule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.Rule] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Rule] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'Rule') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Rule") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -211,18 +314,18 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - 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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -230,15 +333,16 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Rule', pipeline_response) + deserialized = self._deserialize("Rule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}"} # type: ignore - + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}" + } @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -252,33 +356,35 @@ async def delete( # pylint: disable=inconsistent-return-statements ) -> None: """Deletes an existing rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str - :param rule_name: The rule name. + :param rule_name: The rule name. Required. :type rule_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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -287,18 +393,17 @@ async def delete( # pylint: disable=inconsistent-return-statements rule_name=rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -309,8 +414,9 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}"} # type: ignore - + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}" + } @distributed_trace_async async def get( @@ -324,33 +430,35 @@ async def get( ) -> _models.Rule: """Retrieves the description for the specified rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str - :param rule_name: The rule name. + :param rule_name: The rule name. Required. :type rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Rule, or the result of cls(response) + :return: Rule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.Rule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Rule] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + cls: ClsType[_models.Rule] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -359,18 +467,17 @@ async def get( rule_name=rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -378,12 +485,13 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Rule', pipeline_response) + deserialized = self._deserialize("Rule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/operations/_subscriptions_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/operations/_subscriptions_operations.py index 608bc9c2ced53..3afcb89678396 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/operations/_subscriptions_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/operations/_subscriptions_operations.py @@ -6,10 +6,19 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,21 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._subscriptions_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_by_topic_request -T = TypeVar('T') +from ...operations._subscriptions_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_topic_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class SubscriptionsOperations: """ .. warning:: @@ -43,7 +63,6 @@ def __init__(self, *args, **kwargs) -> None: 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_topic( self, @@ -53,14 +72,14 @@ def list_by_topic( skip: Optional[int] = None, top: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable[_models.SBSubscriptionListResult]: + ) -> AsyncIterable["_models.SBSubscription"]: """List all the subscriptions under a specified topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str :param skip: Skip is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skip @@ -70,56 +89,58 @@ def list_by_topic( Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBSubscriptionListResult or the result of - cls(response) + :return: An iterator like instance of either SBSubscription or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.SBSubscriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.SBSubscription] + :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', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBSubscriptionListResult] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + cls: ClsType[_models.SBSubscriptionListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_topic_request( resource_group_name=resource_group_name, namespace_name=namespace_name, topic_name=topic_name, subscription_id=self._config.subscription_id, - api_version=api_version, skip=skip, top=top, - template_url=self.list_by_topic.metadata['url'], + api_version=api_version, + template_url=self.list_by_topic.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_by_topic_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - topic_name=topic_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - skip=skip, - top=top, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -127,16 +148,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("SBSubscriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -147,13 +166,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_topic.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions"} # type: ignore + list_by_topic.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions" + } - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, @@ -161,38 +180,117 @@ async def create_or_update( topic_name: str, subscription_name: str, parameters: _models.SBSubscription, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SBSubscription: """Creates a topic subscription. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str - :param parameters: Parameters supplied to create a subscription resource. + :param parameters: Parameters supplied to create a subscription resource. Required. :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.SBSubscription + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBSubscription, or the result of cls(response) + :return: SBSubscription or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.SBSubscription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBSubscription: + """Creates a topic subscription. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param parameters: Parameters supplied to create a subscription resource. Required. + :type 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: SBSubscription or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.SBSubscription + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + parameters: Union[_models.SBSubscription, IO], + **kwargs: Any + ) -> _models.SBSubscription: + """Creates a topic subscription. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param parameters: Parameters supplied to create a subscription resource. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.SBSubscription 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: SBSubscription or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.SBSubscription + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBSubscription] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SBSubscription] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'SBSubscription') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBSubscription") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -203,18 +301,18 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - 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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -222,52 +320,50 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBSubscription', pipeline_response) + deserialized = self._deserialize("SBSubscription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}"} # type: ignore - + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}" + } @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - subscription_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, topic_name: str, subscription_name: str, **kwargs: Any ) -> None: """Deletes a subscription from the specified topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -275,18 +371,17 @@ async def delete( # pylint: disable=inconsistent-return-statements subscription_name=subscription_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -297,45 +392,43 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}"} # type: ignore - + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}" + } @distributed_trace_async async def get( - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - subscription_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, topic_name: str, subscription_name: str, **kwargs: Any ) -> _models.SBSubscription: """Returns a subscription description for the specified topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBSubscription, or the result of cls(response) + :return: SBSubscription or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.SBSubscription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBSubscription] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + cls: ClsType[_models.SBSubscription] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -343,18 +436,17 @@ async def get( subscription_name=subscription_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -362,12 +454,13 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBSubscription', pipeline_response) + deserialized = self._deserialize("SBSubscription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/operations/_topics_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/operations/_topics_operations.py index 5bc983be15ea0..dd10fcd321b4c 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/operations/_topics_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/operations/_topics_operations.py @@ -6,10 +6,19 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,27 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._topics_operations import build_create_or_update_authorization_rule_request, build_create_or_update_request, build_delete_authorization_rule_request, build_delete_request, build_get_authorization_rule_request, build_get_request, build_list_authorization_rules_request, build_list_by_namespace_request, build_list_keys_request, build_regenerate_keys_request -T = TypeVar('T') +from ...operations._topics_operations import ( + build_create_or_update_authorization_rule_request, + build_create_or_update_request, + build_delete_authorization_rule_request, + build_delete_request, + build_get_authorization_rule_request, + build_get_request, + build_list_authorization_rules_request, + build_list_by_namespace_request, + build_list_keys_request, + build_regenerate_keys_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class TopicsOperations: """ .. warning:: @@ -43,70 +69,69 @@ def __init__(self, *args, **kwargs) -> None: 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_authorization_rules( - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.SBAuthorizationRuleListResult]: + self, resource_group_name: str, namespace_name: str, topic_name: str, **kwargs: Any + ) -> AsyncIterable["_models.SBAuthorizationRule"]: """Gets authorization rules for a topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of - cls(response) + :return: An iterator like instance of either SBAuthorizationRule or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.SBAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.SBAuthorizationRule] + :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', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRuleListResult] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + cls: ClsType[_models.SBAuthorizationRuleListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_authorization_rules_request( resource_group_name=resource_group_name, namespace_name=namespace_name, topic_name=topic_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_authorization_rules.metadata['url'], + template_url=self.list_authorization_rules.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_authorization_rules_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - topic_name=topic_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -114,16 +139,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("SBAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -134,13 +157,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_authorization_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules"} # type: ignore + list_authorization_rules.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules" + } - @distributed_trace_async + @overload async def create_or_update_authorization_rule( self, resource_group_name: str, @@ -148,38 +171,117 @@ async def create_or_update_authorization_rule( topic_name: str, authorization_rule_name: str, parameters: _models.SBAuthorizationRule, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SBAuthorizationRule: """Creates an authorization rule for the specified topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: The shared access authorization rule. + :param parameters: The shared access authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.SBAuthorizationRule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBAuthorizationRule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates an authorization rule for the specified topic. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Required. + :type 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: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: Union[_models.SBAuthorizationRule, IO], + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates an authorization rule for the specified topic. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.SBAuthorizationRule 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: SBAuthorizationRule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SBAuthorizationRule] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'SBAuthorizationRule') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBAuthorizationRule") request = build_create_or_update_authorization_rule_request( resource_group_name=resource_group_name, @@ -190,18 +292,18 @@ async def create_or_update_authorization_rule( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_authorization_rule.metadata['url'], + content=_content, + template_url=self.create_or_update_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -209,15 +311,16 @@ async def create_or_update_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}"} # type: ignore - + create_or_update_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}" + } @distributed_trace_async async def get_authorization_rule( @@ -230,31 +333,33 @@ async def get_authorization_rule( ) -> _models.SBAuthorizationRule: """Returns the specified authorization rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + cls: ClsType[_models.SBAuthorizationRule] = kwargs.pop("cls", None) - request = build_get_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -262,18 +367,17 @@ async def get_authorization_rule( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_authorization_rule.metadata['url'], + template_url=self.get_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -281,15 +385,16 @@ async def get_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}"} # type: ignore - + get_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}" + } @distributed_trace_async async def delete_authorization_rule( # pylint: disable=inconsistent-return-statements @@ -302,31 +407,33 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat ) -> None: """Deletes a topic authorization rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -334,18 +441,17 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_authorization_rule.metadata['url'], + template_url=self.delete_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -356,8 +462,9 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat if cls: return cls(pipeline_response, None, {}) - delete_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}"} # type: ignore - + delete_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}" + } @distributed_trace_async async def list_keys( @@ -370,31 +477,33 @@ async def list_keys( ) -> _models.AccessKeys: """Gets the primary and secondary connection strings for the topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + cls: ClsType[_models.AccessKeys] = kwargs.pop("cls", None) - request = build_list_keys_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -402,18 +511,17 @@ async def list_keys( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata['url'], + 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 + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -421,17 +529,18 @@ async def list_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + deserialized = self._deserialize("AccessKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/ListKeys"} # type: ignore - + list_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/ListKeys" + } - @distributed_trace_async + @overload async def regenerate_keys( self, resource_group_name: str, @@ -439,38 +548,117 @@ async def regenerate_keys( topic_name: str, authorization_rule_name: str, parameters: _models.RegenerateAccessKeyParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.AccessKeys: """Regenerates primary or secondary connection strings for the topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate the authorization rule. + :param parameters: Parameters supplied to regenerate the authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.RegenerateAccessKeyParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AccessKeys: + """Regenerates primary or secondary connection strings for the topic. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Required. + :type 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: AccessKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: Union[_models.RegenerateAccessKeyParameters, IO], + **kwargs: Any + ) -> _models.AccessKeys: + """Regenerates primary or secondary connection strings for the topic. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.RegenerateAccessKeyParameters 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: AccessKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AccessKeys] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RegenerateAccessKeyParameters") request = build_regenerate_keys_request( resource_group_name=resource_group_name, @@ -481,18 +669,18 @@ async def regenerate_keys( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_keys.metadata['url'], + content=_content, + template_url=self.regenerate_keys.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -500,15 +688,16 @@ async def regenerate_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + deserialized = self._deserialize("AccessKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/regenerateKeys"} # type: ignore - + regenerate_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/regenerateKeys" + } @distributed_trace def list_by_namespace( @@ -518,12 +707,12 @@ def list_by_namespace( skip: Optional[int] = None, top: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable[_models.SBTopicListResult]: + ) -> AsyncIterable["_models.SBTopic"]: """Gets all the topics in a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :param skip: Skip is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skip @@ -533,53 +722,57 @@ def list_by_namespace( Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBTopicListResult or the result of cls(response) + :return: An iterator like instance of either SBTopic or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.SBTopicListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.SBTopic] + :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', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBTopicListResult] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + cls: ClsType[_models.SBTopicListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_namespace_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, - api_version=api_version, skip=skip, top=top, - template_url=self.list_by_namespace.metadata['url'], + api_version=api_version, + template_url=self.list_by_namespace.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_by_namespace_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - skip=skip, - top=top, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -587,16 +780,14 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("SBTopicListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -607,49 +798,122 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_namespace.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics"} # type: ignore + list_by_namespace.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics" + } - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, namespace_name: str, topic_name: str, parameters: _models.SBTopic, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SBTopic: """Creates a topic in the specified namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param parameters: Parameters supplied to create a topic resource. + :param parameters: Parameters supplied to create a topic resource. Required. :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.SBTopic + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBTopic or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.SBTopic + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBTopic: + """Creates a topic in the specified namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param parameters: Parameters supplied to create a topic resource. Required. + :type 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: SBTopic, or the result of cls(response) + :return: SBTopic or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.SBTopic - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + parameters: Union[_models.SBTopic, IO], + **kwargs: Any + ) -> _models.SBTopic: + """Creates a topic in the specified namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param parameters: Parameters supplied to create a topic resource. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.SBTopic 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: SBTopic or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.SBTopic + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBTopic] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SBTopic] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'SBTopic') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBTopic") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -659,18 +923,18 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - 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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -678,67 +942,65 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBTopic', pipeline_response) + deserialized = self._deserialize("SBTopic", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}"} # type: ignore - + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}" + } @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, topic_name: str, **kwargs: Any ) -> None: """Deletes a topic from the specified namespace and resource group. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, topic_name=topic_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -749,60 +1011,58 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}"} # type: ignore - + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}" + } @distributed_trace_async async def get( - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, topic_name: str, **kwargs: Any ) -> _models.SBTopic: """Returns a description for the specified topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBTopic, or the result of cls(response) + :return: SBTopic or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.SBTopic - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBTopic] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + cls: ClsType[_models.SBTopic] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, topic_name=topic_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -810,12 +1070,13 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBTopic', pipeline_response) + deserialized = self._deserialize("SBTopic", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/models/__init__.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/models/__init__.py index 078e68dd0be71..86173dc24c8d7 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/models/__init__.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/models/__init__.py @@ -63,103 +63,101 @@ from ._models_py3 import UserAssignedIdentity from ._models_py3 import UserAssignedIdentityProperties - -from ._service_bus_management_client_enums import ( - AccessRights, - CreatedByType, - DefaultAction, - EndPointProvisioningState, - EntityStatus, - FilterType, - KeyType, - ManagedServiceIdentityType, - MigrationConfigurationName, - NetworkRuleIPAction, - PrivateLinkConnectionStatus, - ProvisioningStateDR, - PublicNetworkAccessFlag, - RoleDisasterRecovery, - SkuName, - SkuTier, - UnavailableReason, -) +from ._service_bus_management_client_enums import AccessRights +from ._service_bus_management_client_enums import CreatedByType +from ._service_bus_management_client_enums import DefaultAction +from ._service_bus_management_client_enums import EndPointProvisioningState +from ._service_bus_management_client_enums import EntityStatus +from ._service_bus_management_client_enums import FilterType +from ._service_bus_management_client_enums import KeyType +from ._service_bus_management_client_enums import ManagedServiceIdentityType +from ._service_bus_management_client_enums import MigrationConfigurationName +from ._service_bus_management_client_enums import NetworkRuleIPAction +from ._service_bus_management_client_enums import PrivateLinkConnectionStatus +from ._service_bus_management_client_enums import ProvisioningStateDR +from ._service_bus_management_client_enums import PublicNetworkAccessFlag +from ._service_bus_management_client_enums import RoleDisasterRecovery +from ._service_bus_management_client_enums import SkuName +from ._service_bus_management_client_enums import SkuTier +from ._service_bus_management_client_enums import UnavailableReason from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'AccessKeys', - 'Action', - 'ArmDisasterRecovery', - 'ArmDisasterRecoveryListResult', - 'CheckNameAvailability', - 'CheckNameAvailabilityResult', - 'ConnectionState', - 'CorrelationFilter', - 'Encryption', - 'ErrorAdditionalInfo', - 'ErrorResponse', - 'ErrorResponseError', - 'FailoverProperties', - 'Identity', - 'KeyVaultProperties', - 'MessageCountDetails', - 'MigrationConfigListResult', - 'MigrationConfigProperties', - 'NWRuleSetIpRules', - 'NWRuleSetVirtualNetworkRules', - 'NetworkRuleSet', - 'NetworkRuleSetListResult', - 'Operation', - 'OperationDisplay', - 'OperationListResult', - 'PrivateEndpoint', - 'PrivateEndpointConnection', - 'PrivateEndpointConnectionListResult', - 'PrivateLinkResource', - 'PrivateLinkResourcesListResult', - 'ProxyResource', - 'RegenerateAccessKeyParameters', - 'Resource', - 'ResourceNamespacePatch', - 'Rule', - 'RuleListResult', - 'SBAuthorizationRule', - 'SBAuthorizationRuleListResult', - 'SBClientAffineProperties', - 'SBNamespace', - 'SBNamespaceListResult', - 'SBNamespaceUpdateParameters', - 'SBQueue', - 'SBQueueListResult', - 'SBSku', - 'SBSubscription', - 'SBSubscriptionListResult', - 'SBTopic', - 'SBTopicListResult', - 'SqlFilter', - 'SqlRuleAction', - 'Subnet', - 'SystemData', - 'TrackedResource', - 'UserAssignedIdentity', - 'UserAssignedIdentityProperties', - 'AccessRights', - 'CreatedByType', - 'DefaultAction', - 'EndPointProvisioningState', - 'EntityStatus', - 'FilterType', - 'KeyType', - 'ManagedServiceIdentityType', - 'MigrationConfigurationName', - 'NetworkRuleIPAction', - 'PrivateLinkConnectionStatus', - 'ProvisioningStateDR', - 'PublicNetworkAccessFlag', - 'RoleDisasterRecovery', - 'SkuName', - 'SkuTier', - 'UnavailableReason', + "AccessKeys", + "Action", + "ArmDisasterRecovery", + "ArmDisasterRecoveryListResult", + "CheckNameAvailability", + "CheckNameAvailabilityResult", + "ConnectionState", + "CorrelationFilter", + "Encryption", + "ErrorAdditionalInfo", + "ErrorResponse", + "ErrorResponseError", + "FailoverProperties", + "Identity", + "KeyVaultProperties", + "MessageCountDetails", + "MigrationConfigListResult", + "MigrationConfigProperties", + "NWRuleSetIpRules", + "NWRuleSetVirtualNetworkRules", + "NetworkRuleSet", + "NetworkRuleSetListResult", + "Operation", + "OperationDisplay", + "OperationListResult", + "PrivateEndpoint", + "PrivateEndpointConnection", + "PrivateEndpointConnectionListResult", + "PrivateLinkResource", + "PrivateLinkResourcesListResult", + "ProxyResource", + "RegenerateAccessKeyParameters", + "Resource", + "ResourceNamespacePatch", + "Rule", + "RuleListResult", + "SBAuthorizationRule", + "SBAuthorizationRuleListResult", + "SBClientAffineProperties", + "SBNamespace", + "SBNamespaceListResult", + "SBNamespaceUpdateParameters", + "SBQueue", + "SBQueueListResult", + "SBSku", + "SBSubscription", + "SBSubscriptionListResult", + "SBTopic", + "SBTopicListResult", + "SqlFilter", + "SqlRuleAction", + "Subnet", + "SystemData", + "TrackedResource", + "UserAssignedIdentity", + "UserAssignedIdentityProperties", + "AccessRights", + "CreatedByType", + "DefaultAction", + "EndPointProvisioningState", + "EntityStatus", + "FilterType", + "KeyType", + "ManagedServiceIdentityType", + "MigrationConfigurationName", + "NetworkRuleIPAction", + "PrivateLinkConnectionStatus", + "ProvisioningStateDR", + "PublicNetworkAccessFlag", + "RoleDisasterRecovery", + "SkuName", + "SkuTier", + "UnavailableReason", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/models/_models_py3.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/models/_models_py3.py index 9149f29eb3f13..0bbe0db2e1089 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/models/_models_py3.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_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,17 +8,27 @@ # -------------------------------------------------------------------------- import datetime +import sys from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from ... import _serialization + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - import __init__ as _models + from .. import models as _models +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object -class AccessKeys(msrest.serialization.Model): +class AccessKeys(_serialization.Model): """Namespace/ServiceBus Connection String. Variables are only populated by the server, and will be ignored when sending a request. @@ -45,32 +56,28 @@ class AccessKeys(msrest.serialization.Model): """ _validation = { - 'primary_connection_string': {'readonly': True}, - 'secondary_connection_string': {'readonly': True}, - 'alias_primary_connection_string': {'readonly': True}, - 'alias_secondary_connection_string': {'readonly': True}, - 'primary_key': {'readonly': True}, - 'secondary_key': {'readonly': True}, - 'key_name': {'readonly': True}, + "primary_connection_string": {"readonly": True}, + "secondary_connection_string": {"readonly": True}, + "alias_primary_connection_string": {"readonly": True}, + "alias_secondary_connection_string": {"readonly": True}, + "primary_key": {"readonly": True}, + "secondary_key": {"readonly": True}, + "key_name": {"readonly": True}, } _attribute_map = { - 'primary_connection_string': {'key': 'primaryConnectionString', 'type': 'str'}, - 'secondary_connection_string': {'key': 'secondaryConnectionString', 'type': 'str'}, - 'alias_primary_connection_string': {'key': 'aliasPrimaryConnectionString', 'type': 'str'}, - 'alias_secondary_connection_string': {'key': 'aliasSecondaryConnectionString', 'type': 'str'}, - 'primary_key': {'key': 'primaryKey', 'type': 'str'}, - 'secondary_key': {'key': 'secondaryKey', 'type': 'str'}, - 'key_name': {'key': 'keyName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - """ - """ - super(AccessKeys, self).__init__(**kwargs) + "primary_connection_string": {"key": "primaryConnectionString", "type": "str"}, + "secondary_connection_string": {"key": "secondaryConnectionString", "type": "str"}, + "alias_primary_connection_string": {"key": "aliasPrimaryConnectionString", "type": "str"}, + "alias_secondary_connection_string": {"key": "aliasSecondaryConnectionString", "type": "str"}, + "primary_key": {"key": "primaryKey", "type": "str"}, + "secondary_key": {"key": "secondaryKey", "type": "str"}, + "key_name": {"key": "keyName", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.primary_connection_string = None self.secondary_connection_string = None self.alias_primary_connection_string = None @@ -80,7 +87,7 @@ def __init__( self.key_name = None -class Action(msrest.serialization.Model): +class Action(_serialization.Model): """Represents the filter actions which are allowed for the transformation of a message that have been matched by a filter expression. :ivar sql_expression: SQL expression. e.g. MyProperty='ABC'. @@ -94,9 +101,9 @@ class Action(msrest.serialization.Model): """ _attribute_map = { - 'sql_expression': {'key': 'sqlExpression', 'type': 'str'}, - 'compatibility_level': {'key': 'compatibilityLevel', 'type': 'int'}, - 'requires_preprocessing': {'key': 'requiresPreprocessing', 'type': 'bool'}, + "sql_expression": {"key": "sqlExpression", "type": "str"}, + "compatibility_level": {"key": "compatibilityLevel", "type": "int"}, + "requires_preprocessing": {"key": "requiresPreprocessing", "type": "bool"}, } def __init__( @@ -104,7 +111,7 @@ def __init__( *, sql_expression: Optional[str] = None, compatibility_level: Optional[int] = None, - requires_preprocessing: Optional[bool] = True, + requires_preprocessing: bool = True, **kwargs ): """ @@ -117,13 +124,13 @@ def __init__( preprocessing. :paramtype requires_preprocessing: bool """ - super(Action, self).__init__(**kwargs) + super().__init__(**kwargs) self.sql_expression = sql_expression self.compatibility_level = compatibility_level self.requires_preprocessing = requires_preprocessing -class ProxyResource(msrest.serialization.Model): +class ProxyResource(_serialization.Model): """Common fields that are returned in the response for all Azure Resource Manager resources. Variables are only populated by the server, and will be ignored when sending a request. @@ -141,26 +148,22 @@ class ProxyResource(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ProxyResource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -186,11 +189,11 @@ class ArmDisasterRecovery(ProxyResource): :vartype system_data: ~azure.mgmt.servicebus.v2021_11_01.models.SystemData :ivar provisioning_state: Provisioning state of the Alias(Disaster Recovery configuration) - possible values 'Accepted' or 'Succeeded' or 'Failed'. Known values are: "Accepted", - "Succeeded", "Failed". + "Succeeded", and "Failed". :vartype provisioning_state: str or ~azure.mgmt.servicebus.v2021_11_01.models.ProvisioningStateDR :ivar pending_replication_operations_count: Number of entities pending to be replicated. - :vartype pending_replication_operations_count: long + :vartype pending_replication_operations_count: int :ivar partner_namespace: ARM Id of the Primary/Secondary eventhub namespace name, which is part of GEO DR pairing. :vartype partner_namespace: str @@ -198,41 +201,35 @@ class ArmDisasterRecovery(ProxyResource): pairing. :vartype alternate_name: str :ivar role: role of namespace in GEO DR - possible values 'Primary' or 'PrimaryNotReplicating' - or 'Secondary'. Known values are: "Primary", "PrimaryNotReplicating", "Secondary". + or 'Secondary'. Known values are: "Primary", "PrimaryNotReplicating", and "Secondary". :vartype role: str or ~azure.mgmt.servicebus.v2021_11_01.models.RoleDisasterRecovery """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'readonly': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'pending_replication_operations_count': {'readonly': True}, - 'role': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"readonly": True}, + "system_data": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "pending_replication_operations_count": {"readonly": True}, + "role": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'pending_replication_operations_count': {'key': 'properties.pendingReplicationOperationsCount', 'type': 'long'}, - 'partner_namespace': {'key': 'properties.partnerNamespace', 'type': 'str'}, - 'alternate_name': {'key': 'properties.alternateName', 'type': 'str'}, - 'role': {'key': 'properties.role', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "pending_replication_operations_count": {"key": "properties.pendingReplicationOperationsCount", "type": "int"}, + "partner_namespace": {"key": "properties.partnerNamespace", "type": "str"}, + "alternate_name": {"key": "properties.alternateName", "type": "str"}, + "role": {"key": "properties.role", "type": "str"}, } - def __init__( - self, - *, - partner_namespace: Optional[str] = None, - alternate_name: Optional[str] = None, - **kwargs - ): + def __init__(self, *, partner_namespace: Optional[str] = None, alternate_name: Optional[str] = None, **kwargs): """ :keyword partner_namespace: ARM Id of the Primary/Secondary eventhub namespace name, which is part of GEO DR pairing. @@ -241,7 +238,7 @@ def __init__( pairing. :paramtype alternate_name: str """ - super(ArmDisasterRecovery, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.provisioning_state = None self.pending_replication_operations_count = None @@ -250,7 +247,7 @@ def __init__( self.role = None -class ArmDisasterRecoveryListResult(msrest.serialization.Model): +class ArmDisasterRecoveryListResult(_serialization.Model): """The result of the List Alias(Disaster Recovery configuration) operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -263,65 +260,55 @@ class ArmDisasterRecoveryListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[ArmDisasterRecovery]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ArmDisasterRecovery]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["_models.ArmDisasterRecovery"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.ArmDisasterRecovery"]] = None, **kwargs): """ :keyword value: List of Alias(Disaster Recovery configurations). :paramtype value: list[~azure.mgmt.servicebus.v2021_11_01.models.ArmDisasterRecovery] """ - super(ArmDisasterRecoveryListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class CheckNameAvailability(msrest.serialization.Model): +class CheckNameAvailability(_serialization.Model): """Description of a Check Name availability request properties. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The Name to check the namespace name availability and The namespace name - can contain only letters, numbers, and hyphens. The namespace must start with a letter, and it - must end with a letter or number. + :ivar name: The Name to check the namespace name availability and The namespace name can + contain only letters, numbers, and hyphens. The namespace must start with a letter, and it must + end with a letter or number. 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 to check the namespace name availability and The namespace - name can contain only letters, numbers, and hyphens. The namespace must start with a letter, - and it must end with a letter or number. + :keyword name: The Name to check the namespace name availability and The namespace name can + contain only letters, numbers, and hyphens. The namespace must start with a letter, and it must + end with a letter or number. Required. :paramtype name: str """ - super(CheckNameAvailability, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class CheckNameAvailabilityResult(msrest.serialization.Model): +class CheckNameAvailabilityResult(_serialization.Model): """Description of a Check Name availability request properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -332,19 +319,19 @@ class CheckNameAvailabilityResult(msrest.serialization.Model): available; otherwise, false. :vartype name_available: bool :ivar reason: The reason for unavailability of a namespace. Known values are: "None", - "InvalidName", "SubscriptionIsDisabled", "NameInUse", "NameInLockdown", + "InvalidName", "SubscriptionIsDisabled", "NameInUse", "NameInLockdown", and "TooManyNamespaceInCurrentSubscription". :vartype reason: str or ~azure.mgmt.servicebus.v2021_11_01.models.UnavailableReason """ _validation = { - 'message': {'readonly': True}, + "message": {"readonly": True}, } _attribute_map = { - 'message': {'key': 'message', 'type': 'str'}, - '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"}, } def __init__( @@ -359,29 +346,29 @@ def __init__( available; otherwise, false. :paramtype name_available: bool :keyword reason: The reason for unavailability of a namespace. Known values are: "None", - "InvalidName", "SubscriptionIsDisabled", "NameInUse", "NameInLockdown", + "InvalidName", "SubscriptionIsDisabled", "NameInUse", "NameInLockdown", and "TooManyNamespaceInCurrentSubscription". :paramtype reason: str or ~azure.mgmt.servicebus.v2021_11_01.models.UnavailableReason """ - super(CheckNameAvailabilityResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.message = None self.name_available = name_available self.reason = reason -class ConnectionState(msrest.serialization.Model): +class ConnectionState(_serialization.Model): """ConnectionState information. :ivar status: Status of the connection. Known values are: "Pending", "Approved", "Rejected", - "Disconnected". + and "Disconnected". :vartype status: str or ~azure.mgmt.servicebus.v2021_11_01.models.PrivateLinkConnectionStatus :ivar description: Description of the connection state. :vartype description: str """ _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, + "status": {"key": "status", "type": "str"}, + "description": {"key": "description", "type": "str"}, } def __init__( @@ -393,17 +380,17 @@ def __init__( ): """ :keyword status: Status of the connection. Known values are: "Pending", "Approved", "Rejected", - "Disconnected". + and "Disconnected". :paramtype status: str or ~azure.mgmt.servicebus.v2021_11_01.models.PrivateLinkConnectionStatus :keyword description: Description of the connection state. :paramtype description: str """ - super(ConnectionState, self).__init__(**kwargs) + super().__init__(**kwargs) self.status = status self.description = description -class CorrelationFilter(msrest.serialization.Model): +class CorrelationFilter(_serialization.Model): """Represents the correlation filter expression. :ivar properties: dictionary object for custom filters. @@ -430,16 +417,16 @@ class CorrelationFilter(msrest.serialization.Model): """ _attribute_map = { - 'properties': {'key': 'properties', 'type': '{str}'}, - 'correlation_id': {'key': 'correlationId', 'type': 'str'}, - 'message_id': {'key': 'messageId', 'type': 'str'}, - 'to': {'key': 'to', 'type': 'str'}, - 'reply_to': {'key': 'replyTo', 'type': 'str'}, - 'label': {'key': 'label', 'type': 'str'}, - 'session_id': {'key': 'sessionId', 'type': 'str'}, - 'reply_to_session_id': {'key': 'replyToSessionId', 'type': 'str'}, - 'content_type': {'key': 'contentType', 'type': 'str'}, - 'requires_preprocessing': {'key': 'requiresPreprocessing', 'type': 'bool'}, + "properties": {"key": "properties", "type": "{str}"}, + "correlation_id": {"key": "correlationId", "type": "str"}, + "message_id": {"key": "messageId", "type": "str"}, + "to": {"key": "to", "type": "str"}, + "reply_to": {"key": "replyTo", "type": "str"}, + "label": {"key": "label", "type": "str"}, + "session_id": {"key": "sessionId", "type": "str"}, + "reply_to_session_id": {"key": "replyToSessionId", "type": "str"}, + "content_type": {"key": "contentType", "type": "str"}, + "requires_preprocessing": {"key": "requiresPreprocessing", "type": "bool"}, } def __init__( @@ -454,7 +441,7 @@ def __init__( session_id: Optional[str] = None, reply_to_session_id: Optional[str] = None, content_type: Optional[str] = None, - requires_preprocessing: Optional[bool] = True, + requires_preprocessing: bool = True, **kwargs ): """ @@ -480,7 +467,7 @@ def __init__( preprocessing. :paramtype requires_preprocessing: bool """ - super(CorrelationFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties self.correlation_id = correlation_id self.message_id = message_id @@ -493,14 +480,13 @@ def __init__( self.requires_preprocessing = requires_preprocessing -class Encryption(msrest.serialization.Model): +class Encryption(_serialization.Model): """Properties to configure Encryption. :ivar key_vault_properties: Properties of KeyVault. :vartype key_vault_properties: list[~azure.mgmt.servicebus.v2021_11_01.models.KeyVaultProperties] - :ivar key_source: Enumerates the possible value of keySource for Encryption. The only - acceptable values to pass in are None and "Microsoft.KeyVault". The default value is + :ivar key_source: Enumerates the possible value of keySource for Encryption. Default value is "Microsoft.KeyVault". :vartype key_source: str :ivar require_infrastructure_encryption: Enable Infrastructure Encryption (Double Encryption). @@ -508,16 +494,16 @@ class Encryption(msrest.serialization.Model): """ _attribute_map = { - 'key_vault_properties': {'key': 'keyVaultProperties', 'type': '[KeyVaultProperties]'}, - 'key_source': {'key': 'keySource', 'type': 'str'}, - 'require_infrastructure_encryption': {'key': 'requireInfrastructureEncryption', 'type': 'bool'}, + "key_vault_properties": {"key": "keyVaultProperties", "type": "[KeyVaultProperties]"}, + "key_source": {"key": "keySource", "type": "str"}, + "require_infrastructure_encryption": {"key": "requireInfrastructureEncryption", "type": "bool"}, } def __init__( self, *, key_vault_properties: Optional[List["_models.KeyVaultProperties"]] = None, - key_source: Optional[str] = "Microsoft.KeyVault", + key_source: Literal["Microsoft.KeyVault"] = "Microsoft.KeyVault", require_infrastructure_encryption: Optional[bool] = None, **kwargs ): @@ -525,21 +511,20 @@ def __init__( :keyword key_vault_properties: Properties of KeyVault. :paramtype key_vault_properties: list[~azure.mgmt.servicebus.v2021_11_01.models.KeyVaultProperties] - :keyword key_source: Enumerates the possible value of keySource for Encryption. The only - acceptable values to pass in are None and "Microsoft.KeyVault". The default value is - "Microsoft.KeyVault". + :keyword key_source: Enumerates the possible value of keySource for Encryption. Default value + is "Microsoft.KeyVault". :paramtype key_source: str :keyword require_infrastructure_encryption: Enable Infrastructure Encryption (Double Encryption). :paramtype require_infrastructure_encryption: bool """ - super(Encryption, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_vault_properties = key_vault_properties self.key_source = key_source self.require_infrastructure_encryption = require_infrastructure_encryption -class ErrorAdditionalInfo(msrest.serialization.Model): +class ErrorAdditionalInfo(_serialization.Model): """The resource management error additional info. Variables are only populated by the server, and will be ignored when sending a request. @@ -547,31 +532,27 @@ class ErrorAdditionalInfo(msrest.serialization.Model): :ivar type: The additional info type. :vartype type: str :ivar info: The additional info. - :vartype info: any + :vartype info: JSON """ _validation = { - 'type': {'readonly': True}, - 'info': {'readonly': True}, + "type": {"readonly": True}, + "info": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'info': {'key': 'info', 'type': 'object'}, + "type": {"key": "type", "type": "str"}, + "info": {"key": "info", "type": "object"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorAdditionalInfo, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.type = None self.info = None -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_serialization.Model): """The resource management error response. :ivar error: The error object. @@ -579,24 +560,19 @@ class ErrorResponse(msrest.serialization.Model): """ _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorResponseError'}, + "error": {"key": "error", "type": "ErrorResponseError"}, } - def __init__( - self, - *, - error: Optional["_models.ErrorResponseError"] = None, - **kwargs - ): + def __init__(self, *, error: Optional["_models.ErrorResponseError"] = None, **kwargs): """ :keyword error: The error object. :paramtype error: ~azure.mgmt.servicebus.v2021_11_01.models.ErrorResponseError """ - super(ErrorResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.error = error -class ErrorResponseError(msrest.serialization.Model): +class ErrorResponseError(_serialization.Model): """The error object. Variables are only populated by the server, and will be ignored when sending a request. @@ -614,28 +590,24 @@ class ErrorResponseError(msrest.serialization.Model): """ _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - 'details': {'readonly': True}, - 'additional_info': {'readonly': True}, + "code": {"readonly": True}, + "message": {"readonly": True}, + "target": {"readonly": True}, + "details": {"readonly": True}, + "additional_info": {"readonly": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ErrorResponse]'}, - 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[ErrorResponse]"}, + "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorResponseError, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.code = None self.message = None self.target = None @@ -643,7 +615,7 @@ def __init__( self.additional_info = None -class FailoverProperties(msrest.serialization.Model): +class FailoverProperties(_serialization.Model): """Safe failover is to indicate the service should wait for pending replication to finish before switching to the secondary. :ivar is_safe_failover: Safe failover is to indicate the service should wait for pending @@ -652,25 +624,20 @@ class FailoverProperties(msrest.serialization.Model): """ _attribute_map = { - 'is_safe_failover': {'key': 'properties.IsSafeFailover', 'type': 'bool'}, + "is_safe_failover": {"key": "properties.IsSafeFailover", "type": "bool"}, } - def __init__( - self, - *, - is_safe_failover: Optional[bool] = None, - **kwargs - ): + def __init__(self, *, is_safe_failover: Optional[bool] = None, **kwargs): """ :keyword is_safe_failover: Safe failover is to indicate the service should wait for pending replication to finish before switching to the secondary. :paramtype is_safe_failover: bool """ - super(FailoverProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.is_safe_failover = is_safe_failover -class Identity(msrest.serialization.Model): +class Identity(_serialization.Model): """Properties to configure User Assigned Identities for Bring your Own Keys. Variables are only populated by the server, and will be ignored when sending a request. @@ -680,7 +647,7 @@ class Identity(msrest.serialization.Model): :ivar tenant_id: TenantId from the KeyVault. :vartype tenant_id: str :ivar type: Type of managed service identity. Known values are: "SystemAssigned", - "UserAssigned", "SystemAssigned, UserAssigned", "None". + "UserAssigned", "SystemAssigned, UserAssigned", and "None". :vartype type: str or ~azure.mgmt.servicebus.v2021_11_01.models.ManagedServiceIdentityType :ivar user_assigned_identities: Properties for User Assigned Identities. :vartype user_assigned_identities: dict[str, @@ -688,15 +655,15 @@ class Identity(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': '{UserAssignedIdentity}'}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "user_assigned_identities": {"key": "userAssignedIdentities", "type": "{UserAssignedIdentity}"}, } def __init__( @@ -708,20 +675,20 @@ def __init__( ): """ :keyword type: Type of managed service identity. Known values are: "SystemAssigned", - "UserAssigned", "SystemAssigned, UserAssigned", "None". + "UserAssigned", "SystemAssigned, UserAssigned", and "None". :paramtype type: str or ~azure.mgmt.servicebus.v2021_11_01.models.ManagedServiceIdentityType :keyword user_assigned_identities: Properties for User Assigned Identities. :paramtype user_assigned_identities: dict[str, ~azure.mgmt.servicebus.v2021_11_01.models.UserAssignedIdentity] """ - super(Identity, 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 KeyVaultProperties(msrest.serialization.Model): +class KeyVaultProperties(_serialization.Model): """Properties to configure keyVault Properties. :ivar key_name: Name of the Key from KeyVault. @@ -735,10 +702,10 @@ class KeyVaultProperties(msrest.serialization.Model): """ _attribute_map = { - 'key_name': {'key': 'keyName', 'type': 'str'}, - 'key_vault_uri': {'key': 'keyVaultUri', 'type': 'str'}, - 'key_version': {'key': 'keyVersion', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'UserAssignedIdentityProperties'}, + "key_name": {"key": "keyName", "type": "str"}, + "key_vault_uri": {"key": "keyVaultUri", "type": "str"}, + "key_version": {"key": "keyVersion", "type": "str"}, + "identity": {"key": "identity", "type": "UserAssignedIdentityProperties"}, } def __init__( @@ -760,54 +727,50 @@ def __init__( :keyword identity: :paramtype identity: ~azure.mgmt.servicebus.v2021_11_01.models.UserAssignedIdentityProperties """ - super(KeyVaultProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_name = key_name self.key_vault_uri = key_vault_uri self.key_version = key_version self.identity = identity -class MessageCountDetails(msrest.serialization.Model): +class MessageCountDetails(_serialization.Model): """Message Count Details. Variables are only populated by the server, and will be ignored when sending a request. :ivar active_message_count: Number of active messages in the queue, topic, or subscription. - :vartype active_message_count: long + :vartype active_message_count: int :ivar dead_letter_message_count: Number of messages that are dead lettered. - :vartype dead_letter_message_count: long + :vartype dead_letter_message_count: int :ivar scheduled_message_count: Number of scheduled messages. - :vartype scheduled_message_count: long + :vartype scheduled_message_count: int :ivar transfer_message_count: Number of messages transferred to another queue, topic, or subscription. - :vartype transfer_message_count: long + :vartype transfer_message_count: int :ivar transfer_dead_letter_message_count: Number of messages transferred into dead letters. - :vartype transfer_dead_letter_message_count: long + :vartype transfer_dead_letter_message_count: int """ _validation = { - 'active_message_count': {'readonly': True}, - 'dead_letter_message_count': {'readonly': True}, - 'scheduled_message_count': {'readonly': True}, - 'transfer_message_count': {'readonly': True}, - 'transfer_dead_letter_message_count': {'readonly': True}, + "active_message_count": {"readonly": True}, + "dead_letter_message_count": {"readonly": True}, + "scheduled_message_count": {"readonly": True}, + "transfer_message_count": {"readonly": True}, + "transfer_dead_letter_message_count": {"readonly": True}, } _attribute_map = { - 'active_message_count': {'key': 'activeMessageCount', 'type': 'long'}, - 'dead_letter_message_count': {'key': 'deadLetterMessageCount', 'type': 'long'}, - 'scheduled_message_count': {'key': 'scheduledMessageCount', 'type': 'long'}, - 'transfer_message_count': {'key': 'transferMessageCount', 'type': 'long'}, - 'transfer_dead_letter_message_count': {'key': 'transferDeadLetterMessageCount', 'type': 'long'}, + "active_message_count": {"key": "activeMessageCount", "type": "int"}, + "dead_letter_message_count": {"key": "deadLetterMessageCount", "type": "int"}, + "scheduled_message_count": {"key": "scheduledMessageCount", "type": "int"}, + "transfer_message_count": {"key": "transferMessageCount", "type": "int"}, + "transfer_dead_letter_message_count": {"key": "transferDeadLetterMessageCount", "type": "int"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(MessageCountDetails, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.active_message_count = None self.dead_letter_message_count = None self.scheduled_message_count = None @@ -815,7 +778,7 @@ def __init__( self.transfer_dead_letter_message_count = None -class MigrationConfigListResult(msrest.serialization.Model): +class MigrationConfigListResult(_serialization.Model): """The result of the List migrationConfigurations operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -828,25 +791,20 @@ class MigrationConfigListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[MigrationConfigProperties]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[MigrationConfigProperties]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["_models.MigrationConfigProperties"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.MigrationConfigProperties"]] = None, **kwargs): """ :keyword value: List of Migration Configs. :paramtype value: list[~azure.mgmt.servicebus.v2021_11_01.models.MigrationConfigProperties] """ - super(MigrationConfigListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None @@ -871,7 +829,7 @@ class MigrationConfigProperties(ProxyResource): :ivar provisioning_state: Provisioning state of Migration Configuration. :vartype provisioning_state: str :ivar pending_replication_operations_count: Number of entities pending to be replicated. - :vartype pending_replication_operations_count: long + :vartype pending_replication_operations_count: int :ivar target_namespace: Existing premium Namespace ARM Id name which has no entities, will be used for migration. :vartype target_namespace: str @@ -883,36 +841,30 @@ class MigrationConfigProperties(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'readonly': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'pending_replication_operations_count': {'readonly': True}, - 'migration_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"readonly": True}, + "system_data": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "pending_replication_operations_count": {"readonly": True}, + "migration_state": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'pending_replication_operations_count': {'key': 'properties.pendingReplicationOperationsCount', 'type': 'long'}, - 'target_namespace': {'key': 'properties.targetNamespace', 'type': 'str'}, - 'post_migration_name': {'key': 'properties.postMigrationName', 'type': 'str'}, - 'migration_state': {'key': 'properties.migrationState', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "pending_replication_operations_count": {"key": "properties.pendingReplicationOperationsCount", "type": "int"}, + "target_namespace": {"key": "properties.targetNamespace", "type": "str"}, + "post_migration_name": {"key": "properties.postMigrationName", "type": "str"}, + "migration_state": {"key": "properties.migrationState", "type": "str"}, } - def __init__( - self, - *, - target_namespace: Optional[str] = None, - post_migration_name: Optional[str] = None, - **kwargs - ): + def __init__(self, *, target_namespace: Optional[str] = None, post_migration_name: Optional[str] = None, **kwargs): """ :keyword target_namespace: Existing premium Namespace ARM Id name which has no entities, will be used for migration. @@ -920,7 +872,7 @@ def __init__( :keyword post_migration_name: Name to access Standard Namespace after migration. :paramtype post_migration_name: str """ - super(MigrationConfigProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.provisioning_state = None self.pending_replication_operations_count = None @@ -949,7 +901,8 @@ class NetworkRuleSet(ProxyResource): :ivar trusted_service_access_enabled: Value that indicates whether Trusted Service Access is Enabled or not. :vartype trusted_service_access_enabled: bool - :ivar default_action: Default Action for Network Rule Set. Known values are: "Allow", "Deny". + :ivar default_action: Default Action for Network Rule Set. Known values are: "Allow" and + "Deny". :vartype default_action: str or ~azure.mgmt.servicebus.v2021_11_01.models.DefaultAction :ivar virtual_network_rules: List VirtualNetwork Rules. :vartype virtual_network_rules: @@ -957,30 +910,30 @@ class NetworkRuleSet(ProxyResource): :ivar ip_rules: List of IpRules. :vartype ip_rules: list[~azure.mgmt.servicebus.v2021_11_01.models.NWRuleSetIpRules] :ivar public_network_access: This determines if traffic is allowed over public network. By - default it is enabled. Known values are: "Enabled", "Disabled". Default value: "Enabled". + default it is enabled. Known values are: "Enabled" and "Disabled". :vartype public_network_access: str or ~azure.mgmt.servicebus.v2021_11_01.models.PublicNetworkAccessFlag """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'readonly': True}, - 'system_data': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"readonly": 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'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'trusted_service_access_enabled': {'key': 'properties.trustedServiceAccessEnabled', 'type': 'bool'}, - 'default_action': {'key': 'properties.defaultAction', 'type': 'str'}, - 'virtual_network_rules': {'key': 'properties.virtualNetworkRules', 'type': '[NWRuleSetVirtualNetworkRules]'}, - 'ip_rules': {'key': 'properties.ipRules', 'type': '[NWRuleSetIpRules]'}, - 'public_network_access': {'key': 'properties.publicNetworkAccess', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "trusted_service_access_enabled": {"key": "properties.trustedServiceAccessEnabled", "type": "bool"}, + "default_action": {"key": "properties.defaultAction", "type": "str"}, + "virtual_network_rules": {"key": "properties.virtualNetworkRules", "type": "[NWRuleSetVirtualNetworkRules]"}, + "ip_rules": {"key": "properties.ipRules", "type": "[NWRuleSetIpRules]"}, + "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, } def __init__( @@ -990,14 +943,14 @@ def __init__( default_action: Optional[Union[str, "_models.DefaultAction"]] = None, virtual_network_rules: Optional[List["_models.NWRuleSetVirtualNetworkRules"]] = None, ip_rules: Optional[List["_models.NWRuleSetIpRules"]] = None, - public_network_access: Optional[Union[str, "_models.PublicNetworkAccessFlag"]] = "Enabled", + public_network_access: Union[str, "_models.PublicNetworkAccessFlag"] = "Enabled", **kwargs ): """ :keyword trusted_service_access_enabled: Value that indicates whether Trusted Service Access is Enabled or not. :paramtype trusted_service_access_enabled: bool - :keyword default_action: Default Action for Network Rule Set. Known values are: "Allow", + :keyword default_action: Default Action for Network Rule Set. Known values are: "Allow" and "Deny". :paramtype default_action: str or ~azure.mgmt.servicebus.v2021_11_01.models.DefaultAction :keyword virtual_network_rules: List VirtualNetwork Rules. @@ -1006,11 +959,11 @@ def __init__( :keyword ip_rules: List of IpRules. :paramtype ip_rules: list[~azure.mgmt.servicebus.v2021_11_01.models.NWRuleSetIpRules] :keyword public_network_access: This determines if traffic is allowed over public network. By - default it is enabled. Known values are: "Enabled", "Disabled". Default value: "Enabled". + default it is enabled. Known values are: "Enabled" and "Disabled". :paramtype public_network_access: str or ~azure.mgmt.servicebus.v2021_11_01.models.PublicNetworkAccessFlag """ - super(NetworkRuleSet, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.trusted_service_access_enabled = trusted_service_access_enabled self.default_action = default_action @@ -1019,7 +972,7 @@ def __init__( self.public_network_access = public_network_access -class NetworkRuleSetListResult(msrest.serialization.Model): +class NetworkRuleSetListResult(_serialization.Model): """The response of the List NetworkRuleSet operation. :ivar value: Result of the List NetworkRuleSet operation. @@ -1030,16 +983,12 @@ class NetworkRuleSetListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[NetworkRuleSet]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[NetworkRuleSet]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["_models.NetworkRuleSet"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.NetworkRuleSet"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Result of the List NetworkRuleSet operation. @@ -1048,44 +997,40 @@ def __init__( list of NetworkRuleSet. :paramtype next_link: str """ - super(NetworkRuleSetListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class NWRuleSetIpRules(msrest.serialization.Model): +class NWRuleSetIpRules(_serialization.Model): """Description of NetWorkRuleSet - IpRules resource. :ivar ip_mask: IP Mask. :vartype ip_mask: str - :ivar action: The IP Filter Action. Known values are: "Allow". Default value: "Allow". + :ivar action: The IP Filter Action. "Allow" :vartype action: str or ~azure.mgmt.servicebus.v2021_11_01.models.NetworkRuleIPAction """ _attribute_map = { - 'ip_mask': {'key': 'ipMask', 'type': 'str'}, - 'action': {'key': 'action', 'type': 'str'}, + "ip_mask": {"key": "ipMask", "type": "str"}, + "action": {"key": "action", "type": "str"}, } def __init__( - self, - *, - ip_mask: Optional[str] = None, - action: Optional[Union[str, "_models.NetworkRuleIPAction"]] = "Allow", - **kwargs + self, *, ip_mask: Optional[str] = None, action: Union[str, "_models.NetworkRuleIPAction"] = "Allow", **kwargs ): """ :keyword ip_mask: IP Mask. :paramtype ip_mask: str - :keyword action: The IP Filter Action. Known values are: "Allow". Default value: "Allow". + :keyword action: The IP Filter Action. "Allow" :paramtype action: str or ~azure.mgmt.servicebus.v2021_11_01.models.NetworkRuleIPAction """ - super(NWRuleSetIpRules, self).__init__(**kwargs) + super().__init__(**kwargs) self.ip_mask = ip_mask self.action = action -class NWRuleSetVirtualNetworkRules(msrest.serialization.Model): +class NWRuleSetVirtualNetworkRules(_serialization.Model): """Description of VirtualNetworkRules - NetworkRules resource. :ivar subnet: Subnet properties. @@ -1096,8 +1041,8 @@ class NWRuleSetVirtualNetworkRules(msrest.serialization.Model): """ _attribute_map = { - 'subnet': {'key': 'subnet', 'type': 'Subnet'}, - 'ignore_missing_vnet_service_endpoint': {'key': 'ignoreMissingVnetServiceEndpoint', 'type': 'bool'}, + "subnet": {"key": "subnet", "type": "Subnet"}, + "ignore_missing_vnet_service_endpoint": {"key": "ignoreMissingVnetServiceEndpoint", "type": "bool"}, } def __init__( @@ -1114,12 +1059,12 @@ def __init__( VNet Service Endpoint. :paramtype ignore_missing_vnet_service_endpoint: bool """ - super(NWRuleSetVirtualNetworkRules, self).__init__(**kwargs) + super().__init__(**kwargs) self.subnet = subnet self.ignore_missing_vnet_service_endpoint = ignore_missing_vnet_service_endpoint -class Operation(msrest.serialization.Model): +class Operation(_serialization.Model): """A Service Bus REST API operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -1133,19 +1078,19 @@ class Operation(msrest.serialization.Model): :ivar origin: Origin of the operation. :vartype origin: str :ivar properties: Properties of the operation. - :vartype properties: any + :vartype properties: JSON """ _validation = { - 'name': {'readonly': True}, + "name": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - 'origin': {'key': 'origin', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'object'}, + "name": {"key": "name", "type": "str"}, + "is_data_action": {"key": "isDataAction", "type": "bool"}, + "display": {"key": "display", "type": "OperationDisplay"}, + "origin": {"key": "origin", "type": "str"}, + "properties": {"key": "properties", "type": "object"}, } def __init__( @@ -1154,7 +1099,7 @@ def __init__( is_data_action: Optional[bool] = None, display: Optional["_models.OperationDisplay"] = None, origin: Optional[str] = None, - properties: Optional[Any] = None, + properties: Optional[JSON] = None, **kwargs ): """ @@ -1165,9 +1110,9 @@ def __init__( :keyword origin: Origin of the operation. :paramtype origin: str :keyword properties: Properties of the operation. - :paramtype properties: any + :paramtype properties: JSON """ - super(Operation, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = None self.is_data_action = is_data_action self.display = display @@ -1175,7 +1120,7 @@ def __init__( self.properties = properties -class OperationDisplay(msrest.serialization.Model): +class OperationDisplay(_serialization.Model): """Operation display payload. Variables are only populated by the server, and will be ignored when sending a request. @@ -1191,33 +1136,29 @@ 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 OperationListResult(msrest.serialization.Model): +class OperationListResult(_serialization.Model): """Result of the request to list ServiceBus 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. @@ -1230,27 +1171,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): """PrivateEndpoint information. :ivar id: The ARM identifier for Private Endpoint. @@ -1258,20 +1195,15 @@ class PrivateEndpoint(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - *, - id: Optional[str] = None, - **kwargs - ): + def __init__(self, *, id: Optional[str] = None, **kwargs): # pylint: disable=redefined-builtin """ :keyword id: The ARM identifier for Private Endpoint. :paramtype id: str """ - super(PrivateEndpoint, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id @@ -1298,28 +1230,31 @@ class PrivateEndpointConnection(ProxyResource): :vartype private_link_service_connection_state: ~azure.mgmt.servicebus.v2021_11_01.models.ConnectionState :ivar provisioning_state: Provisioning state of the Private Endpoint Connection. Known values - are: "Creating", "Updating", "Deleting", "Succeeded", "Canceled", "Failed". + are: "Creating", "Updating", "Deleting", "Succeeded", "Canceled", and "Failed". :vartype provisioning_state: str or ~azure.mgmt.servicebus.v2021_11_01.models.EndPointProvisioningState """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'readonly': True}, - 'system_data': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"readonly": 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'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'private_endpoint': {'key': 'properties.privateEndpoint', 'type': 'PrivateEndpoint'}, - 'private_link_service_connection_state': {'key': 'properties.privateLinkServiceConnectionState', 'type': 'ConnectionState'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "private_endpoint": {"key": "properties.privateEndpoint", "type": "PrivateEndpoint"}, + "private_link_service_connection_state": { + "key": "properties.privateLinkServiceConnectionState", + "type": "ConnectionState", + }, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, } def __init__( @@ -1337,18 +1272,18 @@ def __init__( :paramtype private_link_service_connection_state: ~azure.mgmt.servicebus.v2021_11_01.models.ConnectionState :keyword provisioning_state: Provisioning state of the Private Endpoint Connection. Known - values are: "Creating", "Updating", "Deleting", "Succeeded", "Canceled", "Failed". + values are: "Creating", "Updating", "Deleting", "Succeeded", "Canceled", and "Failed". :paramtype provisioning_state: str or ~azure.mgmt.servicebus.v2021_11_01.models.EndPointProvisioningState """ - super(PrivateEndpointConnection, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.private_endpoint = private_endpoint self.private_link_service_connection_state = private_link_service_connection_state self.provisioning_state = provisioning_state -class PrivateEndpointConnectionListResult(msrest.serialization.Model): +class PrivateEndpointConnectionListResult(_serialization.Model): """Result of the list of all private endpoint connections operation. :ivar value: A collection of private endpoint connection resources. @@ -1358,8 +1293,8 @@ class PrivateEndpointConnectionListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PrivateEndpointConnection]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[PrivateEndpointConnection]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( @@ -1375,12 +1310,12 @@ def __init__( :keyword next_link: A link for the next page of private endpoint connection resources. :paramtype next_link: str """ - super(PrivateEndpointConnectionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class PrivateLinkResource(msrest.serialization.Model): +class PrivateLinkResource(_serialization.Model): """Information of the private link resource. :ivar id: Fully qualified identifier of the resource. @@ -1398,18 +1333,18 @@ class PrivateLinkResource(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'group_id': {'key': 'properties.groupId', 'type': 'str'}, - 'required_members': {'key': 'properties.requiredMembers', 'type': '[str]'}, - 'required_zone_names': {'key': 'properties.requiredZoneNames', 'type': '[str]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "group_id": {"key": "properties.groupId", "type": "str"}, + "required_members": {"key": "properties.requiredMembers", "type": "[str]"}, + "required_zone_names": {"key": "properties.requiredZoneNames", "type": "[str]"}, } def __init__( self, *, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin name: Optional[str] = None, type: Optional[str] = None, group_id: Optional[str] = None, @@ -1431,7 +1366,7 @@ def __init__( :keyword required_zone_names: Required Zone Names. :paramtype required_zone_names: list[str] """ - super(PrivateLinkResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.name = name self.type = type @@ -1440,7 +1375,7 @@ def __init__( self.required_zone_names = required_zone_names -class PrivateLinkResourcesListResult(msrest.serialization.Model): +class PrivateLinkResourcesListResult(_serialization.Model): """Result of the List private link resources operation. :ivar value: A collection of private link resources. @@ -1450,16 +1385,12 @@ class PrivateLinkResourcesListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PrivateLinkResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[PrivateLinkResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["_models.PrivateLinkResource"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.PrivateLinkResource"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: A collection of private link resources. @@ -1467,17 +1398,17 @@ def __init__( :keyword next_link: A link for the next page of private link resources. :paramtype next_link: str """ - super(PrivateLinkResourcesListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class RegenerateAccessKeyParameters(msrest.serialization.Model): +class RegenerateAccessKeyParameters(_serialization.Model): """Parameters supplied to the Regenerate Authorization Rule operation, specifies which key needs to be reset. All required parameters must be populated in order to send to Azure. - :ivar key_type: Required. The access key to regenerate. Known values are: "PrimaryKey", + :ivar key_type: The access key to regenerate. Required. Known values are: "PrimaryKey" and "SecondaryKey". :vartype key_type: str or ~azure.mgmt.servicebus.v2021_11_01.models.KeyType :ivar key: Optional, if the key value provided, is reset for KeyType value or autogenerate Key @@ -1486,35 +1417,29 @@ class RegenerateAccessKeyParameters(msrest.serialization.Model): """ _validation = { - 'key_type': {'required': True}, + "key_type": {"required": True}, } _attribute_map = { - 'key_type': {'key': 'keyType', 'type': 'str'}, - 'key': {'key': 'key', 'type': 'str'}, + "key_type": {"key": "keyType", "type": "str"}, + "key": {"key": "key", "type": "str"}, } - def __init__( - self, - *, - key_type: Union[str, "_models.KeyType"], - key: Optional[str] = None, - **kwargs - ): + def __init__(self, *, key_type: Union[str, "_models.KeyType"], key: Optional[str] = None, **kwargs): """ - :keyword key_type: Required. The access key to regenerate. Known values are: "PrimaryKey", + :keyword key_type: The access key to regenerate. Required. Known values are: "PrimaryKey" and "SecondaryKey". :paramtype key_type: str or ~azure.mgmt.servicebus.v2021_11_01.models.KeyType :keyword key: Optional, if the key value provided, is reset for KeyType value or autogenerate Key value set for keyType. :paramtype key: str """ - super(RegenerateAccessKeyParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_type = key_type self.key = key -class Resource(msrest.serialization.Model): +class Resource(_serialization.Model): """The Resource definition for other than namespace. Variables are only populated by the server, and will be ignored when sending a request. @@ -1528,24 +1453,20 @@ class Resource(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(Resource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -1564,38 +1485,32 @@ class ResourceNamespacePatch(Resource): :vartype type: str :ivar location: Resource location. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"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}'}, + "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: Optional[str] = None, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, **kwargs): """ :keyword location: Resource location. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] """ - super(ResourceNamespacePatch, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.tags = tags @@ -1621,7 +1536,7 @@ class Rule(ProxyResource): message that have been matched by a filter expression. :vartype action: ~azure.mgmt.servicebus.v2021_11_01.models.Action :ivar filter_type: Filter type that is evaluated against a BrokeredMessage. Known values are: - "SqlFilter", "CorrelationFilter". + "SqlFilter" and "CorrelationFilter". :vartype filter_type: str or ~azure.mgmt.servicebus.v2021_11_01.models.FilterType :ivar sql_filter: Properties of sqlFilter. :vartype sql_filter: ~azure.mgmt.servicebus.v2021_11_01.models.SqlFilter @@ -1630,23 +1545,23 @@ class Rule(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'readonly': True}, - 'system_data': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"readonly": 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'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'action': {'key': 'properties.action', 'type': 'Action'}, - 'filter_type': {'key': 'properties.filterType', 'type': 'str'}, - 'sql_filter': {'key': 'properties.sqlFilter', 'type': 'SqlFilter'}, - 'correlation_filter': {'key': 'properties.correlationFilter', 'type': 'CorrelationFilter'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "action": {"key": "properties.action", "type": "Action"}, + "filter_type": {"key": "properties.filterType", "type": "str"}, + "sql_filter": {"key": "properties.sqlFilter", "type": "SqlFilter"}, + "correlation_filter": {"key": "properties.correlationFilter", "type": "CorrelationFilter"}, } def __init__( @@ -1663,14 +1578,14 @@ def __init__( message that have been matched by a filter expression. :paramtype action: ~azure.mgmt.servicebus.v2021_11_01.models.Action :keyword filter_type: Filter type that is evaluated against a BrokeredMessage. Known values - are: "SqlFilter", "CorrelationFilter". + are: "SqlFilter" and "CorrelationFilter". :paramtype filter_type: str or ~azure.mgmt.servicebus.v2021_11_01.models.FilterType :keyword sql_filter: Properties of sqlFilter. :paramtype sql_filter: ~azure.mgmt.servicebus.v2021_11_01.models.SqlFilter :keyword correlation_filter: Properties of correlationFilter. :paramtype correlation_filter: ~azure.mgmt.servicebus.v2021_11_01.models.CorrelationFilter """ - super(Rule, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.action = action self.filter_type = filter_type @@ -1678,7 +1593,7 @@ def __init__( self.correlation_filter = correlation_filter -class RuleListResult(msrest.serialization.Model): +class RuleListResult(_serialization.Model): """The response of the List rule operation. :ivar value: Result of the List Rules operation. @@ -1689,17 +1604,11 @@ class RuleListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Rule]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Rule]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["_models.Rule"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Rule"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: Result of the List Rules operation. :paramtype value: list[~azure.mgmt.servicebus.v2021_11_01.models.Rule] @@ -1707,7 +1616,7 @@ def __init__( list of rules. :paramtype next_link: str """ - super(RuleListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link @@ -1734,38 +1643,33 @@ class SBAuthorizationRule(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'readonly': True}, - 'system_data': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"readonly": 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'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'rights': {'key': 'properties.rights', 'type': '[str]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "rights": {"key": "properties.rights", "type": "[str]"}, } - def __init__( - self, - *, - rights: Optional[List[Union[str, "_models.AccessRights"]]] = None, - **kwargs - ): + def __init__(self, *, rights: Optional[List[Union[str, "_models.AccessRights"]]] = None, **kwargs): """ :keyword rights: The rights associated with the rule. :paramtype rights: list[str or ~azure.mgmt.servicebus.v2021_11_01.models.AccessRights] """ - super(SBAuthorizationRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.rights = rights -class SBAuthorizationRuleListResult(msrest.serialization.Model): +class SBAuthorizationRuleListResult(_serialization.Model): """The response to the List Namespace operation. :ivar value: Result of the List Authorization Rules operation. @@ -1776,16 +1680,12 @@ class SBAuthorizationRuleListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[SBAuthorizationRule]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SBAuthorizationRule]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["_models.SBAuthorizationRule"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.SBAuthorizationRule"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Result of the List Authorization Rules operation. @@ -1794,12 +1694,12 @@ def __init__( list of Authorization Rules. :paramtype next_link: str """ - super(SBAuthorizationRuleListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class SBClientAffineProperties(msrest.serialization.Model): +class SBClientAffineProperties(_serialization.Model): """Properties specific to client affine subscriptions. :ivar client_id: Indicates the Client ID of the application that created the client-affine @@ -1814,9 +1714,9 @@ class SBClientAffineProperties(msrest.serialization.Model): """ _attribute_map = { - 'client_id': {'key': 'clientId', 'type': 'str'}, - 'is_durable': {'key': 'isDurable', 'type': 'bool'}, - 'is_shared': {'key': 'isShared', 'type': 'bool'}, + "client_id": {"key": "clientId", "type": "str"}, + "is_durable": {"key": "isDurable", "type": "bool"}, + "is_shared": {"key": "isShared", "type": "bool"}, } def __init__( @@ -1838,7 +1738,7 @@ def __init__( subscription is shared or not. :paramtype is_shared: bool """ - super(SBClientAffineProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.client_id = client_id self.is_durable = is_durable self.is_shared = is_shared @@ -1857,46 +1757,40 @@ class TrackedResource(Resource): :vartype name: str :ivar type: Resource type. :vartype type: str - :ivar location: Required. The Geo-location where the resource lives. + :ivar location: The Geo-location where the resource lives. Required. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "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 Geo-location where the resource lives. + :keyword location: The Geo-location where the resource lives. Required. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] """ - super(TrackedResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.tags = tags -class SBNamespace(TrackedResource): +class SBNamespace(TrackedResource): # pylint: disable=too-many-instance-attributes """Description of a namespace resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -1909,9 +1803,9 @@ class SBNamespace(TrackedResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :ivar location: Required. The Geo-location where the resource lives. + :ivar location: The Geo-location where the resource lives. Required. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar sku: Properties of SKU. :vartype sku: ~azure.mgmt.servicebus.v2021_11_01.models.SBSku @@ -1947,39 +1841,42 @@ class SBNamespace(TrackedResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'status': {'readonly': True}, - 'created_at': {'readonly': True}, - 'updated_at': {'readonly': True}, - 'service_bus_endpoint': {'readonly': True}, - 'metric_id': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "system_data": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "status": {"readonly": True}, + "created_at": {"readonly": True}, + "updated_at": {"readonly": True}, + "service_bus_endpoint": {"readonly": True}, + "metric_id": {"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}'}, - 'sku': {'key': 'sku', 'type': 'SBSku'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'created_at': {'key': 'properties.createdAt', 'type': 'iso-8601'}, - 'updated_at': {'key': 'properties.updatedAt', 'type': 'iso-8601'}, - 'service_bus_endpoint': {'key': 'properties.serviceBusEndpoint', 'type': 'str'}, - 'metric_id': {'key': 'properties.metricId', 'type': 'str'}, - 'zone_redundant': {'key': 'properties.zoneRedundant', 'type': 'bool'}, - 'encryption': {'key': 'properties.encryption', 'type': 'Encryption'}, - 'private_endpoint_connections': {'key': 'properties.privateEndpointConnections', 'type': '[PrivateEndpointConnection]'}, - 'disable_local_auth': {'key': 'properties.disableLocalAuth', 'type': 'bool'}, - 'alternate_name': {'key': 'properties.alternateName', '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}"}, + "sku": {"key": "sku", "type": "SBSku"}, + "identity": {"key": "identity", "type": "Identity"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "status": {"key": "properties.status", "type": "str"}, + "created_at": {"key": "properties.createdAt", "type": "iso-8601"}, + "updated_at": {"key": "properties.updatedAt", "type": "iso-8601"}, + "service_bus_endpoint": {"key": "properties.serviceBusEndpoint", "type": "str"}, + "metric_id": {"key": "properties.metricId", "type": "str"}, + "zone_redundant": {"key": "properties.zoneRedundant", "type": "bool"}, + "encryption": {"key": "properties.encryption", "type": "Encryption"}, + "private_endpoint_connections": { + "key": "properties.privateEndpointConnections", + "type": "[PrivateEndpointConnection]", + }, + "disable_local_auth": {"key": "properties.disableLocalAuth", "type": "bool"}, + "alternate_name": {"key": "properties.alternateName", "type": "str"}, } def __init__( @@ -1997,9 +1894,9 @@ def __init__( **kwargs ): """ - :keyword location: Required. The Geo-location where the resource lives. + :keyword location: The Geo-location where the resource lives. Required. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword sku: Properties of SKU. :paramtype sku: ~azure.mgmt.servicebus.v2021_11_01.models.SBSku @@ -2019,7 +1916,7 @@ def __init__( :keyword alternate_name: Alternate name for namespace. :paramtype alternate_name: str """ - super(SBNamespace, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.sku = sku self.identity = identity self.system_data = None @@ -2036,7 +1933,7 @@ def __init__( self.alternate_name = alternate_name -class SBNamespaceListResult(msrest.serialization.Model): +class SBNamespaceListResult(_serialization.Model): """The response of the List Namespace operation. :ivar value: Result of the List Namespace operation. @@ -2047,16 +1944,12 @@ class SBNamespaceListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[SBNamespace]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SBNamespace]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["_models.SBNamespace"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.SBNamespace"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Result of the List Namespace operation. @@ -2065,12 +1958,12 @@ def __init__( list of Namespaces. :paramtype next_link: str """ - super(SBNamespaceListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class SBNamespaceUpdateParameters(ResourceNamespacePatch): +class SBNamespaceUpdateParameters(ResourceNamespacePatch): # pylint: disable=too-many-instance-attributes """Description of a namespace resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -2083,7 +1976,7 @@ class SBNamespaceUpdateParameters(ResourceNamespacePatch): :vartype type: str :ivar location: Resource location. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar sku: Properties of SKU. :vartype sku: ~azure.mgmt.servicebus.v2021_11_01.models.SBSku @@ -2114,35 +2007,38 @@ class SBNamespaceUpdateParameters(ResourceNamespacePatch): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'status': {'readonly': True}, - 'created_at': {'readonly': True}, - 'updated_at': {'readonly': True}, - 'service_bus_endpoint': {'readonly': True}, - 'metric_id': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "status": {"readonly": True}, + "created_at": {"readonly": True}, + "updated_at": {"readonly": True}, + "service_bus_endpoint": {"readonly": True}, + "metric_id": {"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}'}, - 'sku': {'key': 'sku', 'type': 'SBSku'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'created_at': {'key': 'properties.createdAt', 'type': 'iso-8601'}, - 'updated_at': {'key': 'properties.updatedAt', 'type': 'iso-8601'}, - 'service_bus_endpoint': {'key': 'properties.serviceBusEndpoint', 'type': 'str'}, - 'metric_id': {'key': 'properties.metricId', 'type': 'str'}, - 'encryption': {'key': 'properties.encryption', 'type': 'Encryption'}, - 'private_endpoint_connections': {'key': 'properties.privateEndpointConnections', 'type': '[PrivateEndpointConnection]'}, - 'disable_local_auth': {'key': 'properties.disableLocalAuth', 'type': 'bool'}, - 'alternate_name': {'key': 'properties.alternateName', '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}"}, + "sku": {"key": "sku", "type": "SBSku"}, + "identity": {"key": "identity", "type": "Identity"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "status": {"key": "properties.status", "type": "str"}, + "created_at": {"key": "properties.createdAt", "type": "iso-8601"}, + "updated_at": {"key": "properties.updatedAt", "type": "iso-8601"}, + "service_bus_endpoint": {"key": "properties.serviceBusEndpoint", "type": "str"}, + "metric_id": {"key": "properties.metricId", "type": "str"}, + "encryption": {"key": "properties.encryption", "type": "Encryption"}, + "private_endpoint_connections": { + "key": "properties.privateEndpointConnections", + "type": "[PrivateEndpointConnection]", + }, + "disable_local_auth": {"key": "properties.disableLocalAuth", "type": "bool"}, + "alternate_name": {"key": "properties.alternateName", "type": "str"}, } def __init__( @@ -2161,7 +2057,7 @@ def __init__( """ :keyword location: Resource location. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword sku: Properties of SKU. :paramtype sku: ~azure.mgmt.servicebus.v2021_11_01.models.SBSku @@ -2178,7 +2074,7 @@ def __init__( :keyword alternate_name: Alternate name for namespace. :paramtype alternate_name: str """ - super(SBNamespaceUpdateParameters, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.sku = sku self.identity = identity self.provisioning_state = None @@ -2193,7 +2089,7 @@ def __init__( self.alternate_name = alternate_name -class SBQueue(ProxyResource): +class SBQueue(ProxyResource): # pylint: disable=too-many-instance-attributes """Description of queue Resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -2220,9 +2116,9 @@ class SBQueue(ProxyResource): to this queue. :vartype accessed_at: ~datetime.datetime :ivar size_in_bytes: The size of the queue, in bytes. - :vartype size_in_bytes: long + :vartype size_in_bytes: int :ivar message_count: The number of messages in the queue. - :vartype message_count: long + :vartype message_count: int :ivar lock_duration: ISO 8601 timespan duration of a peek-lock; that is, the amount of time that the message is locked for other receivers. The maximum value for LockDuration is 5 minutes; the default value is 1 minute. @@ -2232,7 +2128,7 @@ class SBQueue(ProxyResource): :vartype max_size_in_megabytes: int :ivar max_message_size_in_kilobytes: Maximum size (in KB) of the message payload that can be accepted by the queue. This property is only used in Premium today and default is 1024. - :vartype max_message_size_in_kilobytes: long + :vartype max_message_size_in_kilobytes: int :ivar requires_duplicate_detection: A value indicating if this queue requires duplicate detection. :vartype requires_duplicate_detection: bool @@ -2254,7 +2150,7 @@ class SBQueue(ProxyResource): :vartype max_delivery_count: int :ivar status: Enumerates the possible values for the status of a messaging entity. Known values are: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", "Creating", - "Deleting", "Renaming", "Unknown". + "Deleting", "Renaming", and "Unknown". :vartype status: str or ~azure.mgmt.servicebus.v2021_11_01.models.EntityStatus :ivar enable_batched_operations: Value that indicates whether server-side batched operations are enabled. @@ -2275,50 +2171,53 @@ class SBQueue(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'readonly': True}, - 'system_data': {'readonly': True}, - 'count_details': {'readonly': True}, - 'created_at': {'readonly': True}, - 'updated_at': {'readonly': True}, - 'accessed_at': {'readonly': True}, - 'size_in_bytes': {'readonly': True}, - 'message_count': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"readonly": True}, + "system_data": {"readonly": True}, + "count_details": {"readonly": True}, + "created_at": {"readonly": True}, + "updated_at": {"readonly": True}, + "accessed_at": {"readonly": True}, + "size_in_bytes": {"readonly": True}, + "message_count": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'count_details': {'key': 'properties.countDetails', 'type': 'MessageCountDetails'}, - 'created_at': {'key': 'properties.createdAt', 'type': 'iso-8601'}, - 'updated_at': {'key': 'properties.updatedAt', 'type': 'iso-8601'}, - 'accessed_at': {'key': 'properties.accessedAt', 'type': 'iso-8601'}, - 'size_in_bytes': {'key': 'properties.sizeInBytes', 'type': 'long'}, - 'message_count': {'key': 'properties.messageCount', 'type': 'long'}, - 'lock_duration': {'key': 'properties.lockDuration', 'type': 'duration'}, - 'max_size_in_megabytes': {'key': 'properties.maxSizeInMegabytes', 'type': 'int'}, - 'max_message_size_in_kilobytes': {'key': 'properties.maxMessageSizeInKilobytes', 'type': 'long'}, - 'requires_duplicate_detection': {'key': 'properties.requiresDuplicateDetection', 'type': 'bool'}, - 'requires_session': {'key': 'properties.requiresSession', 'type': 'bool'}, - 'default_message_time_to_live': {'key': 'properties.defaultMessageTimeToLive', 'type': 'duration'}, - 'dead_lettering_on_message_expiration': {'key': 'properties.deadLetteringOnMessageExpiration', 'type': 'bool'}, - 'duplicate_detection_history_time_window': {'key': 'properties.duplicateDetectionHistoryTimeWindow', 'type': 'duration'}, - 'max_delivery_count': {'key': 'properties.maxDeliveryCount', 'type': 'int'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'enable_batched_operations': {'key': 'properties.enableBatchedOperations', 'type': 'bool'}, - 'auto_delete_on_idle': {'key': 'properties.autoDeleteOnIdle', 'type': 'duration'}, - 'enable_partitioning': {'key': 'properties.enablePartitioning', 'type': 'bool'}, - 'enable_express': {'key': 'properties.enableExpress', 'type': 'bool'}, - 'forward_to': {'key': 'properties.forwardTo', 'type': 'str'}, - 'forward_dead_lettered_messages_to': {'key': 'properties.forwardDeadLetteredMessagesTo', 'type': 'str'}, - } - - def __init__( + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "count_details": {"key": "properties.countDetails", "type": "MessageCountDetails"}, + "created_at": {"key": "properties.createdAt", "type": "iso-8601"}, + "updated_at": {"key": "properties.updatedAt", "type": "iso-8601"}, + "accessed_at": {"key": "properties.accessedAt", "type": "iso-8601"}, + "size_in_bytes": {"key": "properties.sizeInBytes", "type": "int"}, + "message_count": {"key": "properties.messageCount", "type": "int"}, + "lock_duration": {"key": "properties.lockDuration", "type": "duration"}, + "max_size_in_megabytes": {"key": "properties.maxSizeInMegabytes", "type": "int"}, + "max_message_size_in_kilobytes": {"key": "properties.maxMessageSizeInKilobytes", "type": "int"}, + "requires_duplicate_detection": {"key": "properties.requiresDuplicateDetection", "type": "bool"}, + "requires_session": {"key": "properties.requiresSession", "type": "bool"}, + "default_message_time_to_live": {"key": "properties.defaultMessageTimeToLive", "type": "duration"}, + "dead_lettering_on_message_expiration": {"key": "properties.deadLetteringOnMessageExpiration", "type": "bool"}, + "duplicate_detection_history_time_window": { + "key": "properties.duplicateDetectionHistoryTimeWindow", + "type": "duration", + }, + "max_delivery_count": {"key": "properties.maxDeliveryCount", "type": "int"}, + "status": {"key": "properties.status", "type": "str"}, + "enable_batched_operations": {"key": "properties.enableBatchedOperations", "type": "bool"}, + "auto_delete_on_idle": {"key": "properties.autoDeleteOnIdle", "type": "duration"}, + "enable_partitioning": {"key": "properties.enablePartitioning", "type": "bool"}, + "enable_express": {"key": "properties.enableExpress", "type": "bool"}, + "forward_to": {"key": "properties.forwardTo", "type": "str"}, + "forward_dead_lettered_messages_to": {"key": "properties.forwardDeadLetteredMessagesTo", "type": "str"}, + } + + def __init__( # pylint: disable=too-many-locals self, *, lock_duration: Optional[datetime.timedelta] = None, @@ -2349,7 +2248,7 @@ def __init__( :paramtype max_size_in_megabytes: int :keyword max_message_size_in_kilobytes: Maximum size (in KB) of the message payload that can be accepted by the queue. This property is only used in Premium today and default is 1024. - :paramtype max_message_size_in_kilobytes: long + :paramtype max_message_size_in_kilobytes: int :keyword requires_duplicate_detection: A value indicating if this queue requires duplicate detection. :paramtype requires_duplicate_detection: bool @@ -2371,7 +2270,7 @@ def __init__( :paramtype max_delivery_count: int :keyword status: Enumerates the possible values for the status of a messaging entity. Known values are: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", "Creating", - "Deleting", "Renaming", "Unknown". + "Deleting", "Renaming", and "Unknown". :paramtype status: str or ~azure.mgmt.servicebus.v2021_11_01.models.EntityStatus :keyword enable_batched_operations: Value that indicates whether server-side batched operations are enabled. @@ -2391,7 +2290,7 @@ def __init__( message. :paramtype forward_dead_lettered_messages_to: str """ - super(SBQueue, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.count_details = None self.created_at = None @@ -2417,7 +2316,7 @@ def __init__( self.forward_dead_lettered_messages_to = forward_dead_lettered_messages_to -class SBQueueListResult(msrest.serialization.Model): +class SBQueueListResult(_serialization.Model): """The response to the List Queues operation. :ivar value: Result of the List Queues operation. @@ -2428,17 +2327,11 @@ class SBQueueListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[SBQueue]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SBQueue]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["_models.SBQueue"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.SBQueue"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: Result of the List Queues operation. :paramtype value: list[~azure.mgmt.servicebus.v2021_11_01.models.SBQueue] @@ -2446,19 +2339,19 @@ def __init__( list of queues. :paramtype next_link: str """ - super(SBQueueListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class SBSku(msrest.serialization.Model): +class SBSku(_serialization.Model): """SKU of the namespace. All required parameters must be populated in order to send to Azure. - :ivar name: Required. Name of this SKU. Known values are: "Basic", "Standard", "Premium". + :ivar name: Name of this SKU. Required. Known values are: "Basic", "Standard", and "Premium". :vartype name: str or ~azure.mgmt.servicebus.v2021_11_01.models.SkuName - :ivar tier: The billing tier of this particular SKU. Known values are: "Basic", "Standard", + :ivar tier: The billing tier of this particular SKU. Known values are: "Basic", "Standard", and "Premium". :vartype tier: str or ~azure.mgmt.servicebus.v2021_11_01.models.SkuTier :ivar capacity: The specified messaging units for the tier. For Premium tier, capacity are 1,2 @@ -2467,13 +2360,13 @@ class SBSku(msrest.serialization.Model): """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'capacity': {'key': 'capacity', 'type': 'int'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "capacity": {"key": "capacity", "type": "int"}, } def __init__( @@ -2485,22 +2378,23 @@ def __init__( **kwargs ): """ - :keyword name: Required. Name of this SKU. Known values are: "Basic", "Standard", "Premium". + :keyword name: Name of this SKU. Required. Known values are: "Basic", "Standard", and + "Premium". :paramtype name: str or ~azure.mgmt.servicebus.v2021_11_01.models.SkuName :keyword tier: The billing tier of this particular SKU. Known values are: "Basic", "Standard", - "Premium". + and "Premium". :paramtype tier: str or ~azure.mgmt.servicebus.v2021_11_01.models.SkuTier :keyword capacity: The specified messaging units for the tier. For Premium tier, capacity are 1,2 and 4. :paramtype capacity: int """ - super(SBSku, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.tier = tier self.capacity = capacity -class SBSubscription(ProxyResource): +class SBSubscription(ProxyResource): # pylint: disable=too-many-instance-attributes """Description of subscription resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -2518,7 +2412,7 @@ class SBSubscription(ProxyResource): :ivar system_data: The system meta data relating to this resource. :vartype system_data: ~azure.mgmt.servicebus.v2021_11_01.models.SystemData :ivar message_count: Number of messages. - :vartype message_count: long + :vartype message_count: int :ivar created_at: Exact time the message was created. :vartype created_at: ~datetime.datetime :ivar accessed_at: Last time there was a receive request to this subscription. @@ -2549,7 +2443,7 @@ class SBSubscription(ProxyResource): :vartype max_delivery_count: int :ivar status: Enumerates the possible values for the status of a messaging entity. Known values are: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", "Creating", - "Deleting", "Renaming", "Unknown". + "Deleting", "Renaming", and "Unknown". :vartype status: str or ~azure.mgmt.servicebus.v2021_11_01.models.EntityStatus :ivar enable_batched_operations: Value that indicates whether server-side batched operations are enabled. @@ -2570,46 +2464,52 @@ class SBSubscription(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'readonly': True}, - 'system_data': {'readonly': True}, - 'message_count': {'readonly': True}, - 'created_at': {'readonly': True}, - 'accessed_at': {'readonly': True}, - 'updated_at': {'readonly': True}, - 'count_details': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"readonly": True}, + "system_data": {"readonly": True}, + "message_count": {"readonly": True}, + "created_at": {"readonly": True}, + "accessed_at": {"readonly": True}, + "updated_at": {"readonly": True}, + "count_details": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'message_count': {'key': 'properties.messageCount', 'type': 'long'}, - 'created_at': {'key': 'properties.createdAt', 'type': 'iso-8601'}, - 'accessed_at': {'key': 'properties.accessedAt', 'type': 'iso-8601'}, - 'updated_at': {'key': 'properties.updatedAt', 'type': 'iso-8601'}, - 'count_details': {'key': 'properties.countDetails', 'type': 'MessageCountDetails'}, - 'lock_duration': {'key': 'properties.lockDuration', 'type': 'duration'}, - 'requires_session': {'key': 'properties.requiresSession', 'type': 'bool'}, - 'default_message_time_to_live': {'key': 'properties.defaultMessageTimeToLive', 'type': 'duration'}, - 'dead_lettering_on_filter_evaluation_exceptions': {'key': 'properties.deadLetteringOnFilterEvaluationExceptions', 'type': 'bool'}, - 'dead_lettering_on_message_expiration': {'key': 'properties.deadLetteringOnMessageExpiration', 'type': 'bool'}, - 'duplicate_detection_history_time_window': {'key': 'properties.duplicateDetectionHistoryTimeWindow', 'type': 'duration'}, - 'max_delivery_count': {'key': 'properties.maxDeliveryCount', 'type': 'int'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'enable_batched_operations': {'key': 'properties.enableBatchedOperations', 'type': 'bool'}, - 'auto_delete_on_idle': {'key': 'properties.autoDeleteOnIdle', 'type': 'duration'}, - 'forward_to': {'key': 'properties.forwardTo', 'type': 'str'}, - 'forward_dead_lettered_messages_to': {'key': 'properties.forwardDeadLetteredMessagesTo', 'type': 'str'}, - 'is_client_affine': {'key': 'properties.isClientAffine', 'type': 'bool'}, - 'client_affine_properties': {'key': 'properties.clientAffineProperties', 'type': 'SBClientAffineProperties'}, - } - - def __init__( + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "message_count": {"key": "properties.messageCount", "type": "int"}, + "created_at": {"key": "properties.createdAt", "type": "iso-8601"}, + "accessed_at": {"key": "properties.accessedAt", "type": "iso-8601"}, + "updated_at": {"key": "properties.updatedAt", "type": "iso-8601"}, + "count_details": {"key": "properties.countDetails", "type": "MessageCountDetails"}, + "lock_duration": {"key": "properties.lockDuration", "type": "duration"}, + "requires_session": {"key": "properties.requiresSession", "type": "bool"}, + "default_message_time_to_live": {"key": "properties.defaultMessageTimeToLive", "type": "duration"}, + "dead_lettering_on_filter_evaluation_exceptions": { + "key": "properties.deadLetteringOnFilterEvaluationExceptions", + "type": "bool", + }, + "dead_lettering_on_message_expiration": {"key": "properties.deadLetteringOnMessageExpiration", "type": "bool"}, + "duplicate_detection_history_time_window": { + "key": "properties.duplicateDetectionHistoryTimeWindow", + "type": "duration", + }, + "max_delivery_count": {"key": "properties.maxDeliveryCount", "type": "int"}, + "status": {"key": "properties.status", "type": "str"}, + "enable_batched_operations": {"key": "properties.enableBatchedOperations", "type": "bool"}, + "auto_delete_on_idle": {"key": "properties.autoDeleteOnIdle", "type": "duration"}, + "forward_to": {"key": "properties.forwardTo", "type": "str"}, + "forward_dead_lettered_messages_to": {"key": "properties.forwardDeadLetteredMessagesTo", "type": "str"}, + "is_client_affine": {"key": "properties.isClientAffine", "type": "bool"}, + "client_affine_properties": {"key": "properties.clientAffineProperties", "type": "SBClientAffineProperties"}, + } + + def __init__( # pylint: disable=too-many-locals self, *, lock_duration: Optional[datetime.timedelta] = None, @@ -2651,7 +2551,7 @@ def __init__( :paramtype max_delivery_count: int :keyword status: Enumerates the possible values for the status of a messaging entity. Known values are: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", "Creating", - "Deleting", "Renaming", "Unknown". + "Deleting", "Renaming", and "Unknown". :paramtype status: str or ~azure.mgmt.servicebus.v2021_11_01.models.EntityStatus :keyword enable_batched_operations: Value that indicates whether server-side batched operations are enabled. @@ -2671,7 +2571,7 @@ def __init__( :paramtype client_affine_properties: ~azure.mgmt.servicebus.v2021_11_01.models.SBClientAffineProperties """ - super(SBSubscription, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.message_count = None self.created_at = None @@ -2694,7 +2594,7 @@ def __init__( self.client_affine_properties = client_affine_properties -class SBSubscriptionListResult(msrest.serialization.Model): +class SBSubscriptionListResult(_serialization.Model): """The response to the List Subscriptions operation. :ivar value: Result of the List Subscriptions operation. @@ -2705,16 +2605,12 @@ class SBSubscriptionListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[SBSubscription]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SBSubscription]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["_models.SBSubscription"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.SBSubscription"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Result of the List Subscriptions operation. @@ -2723,12 +2619,12 @@ def __init__( list of subscriptions. :paramtype next_link: str """ - super(SBSubscriptionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class SBTopic(ProxyResource): +class SBTopic(ProxyResource): # pylint: disable=too-many-instance-attributes """Description of topic resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -2746,7 +2642,7 @@ class SBTopic(ProxyResource): :ivar system_data: The system meta data relating to this resource. :vartype system_data: ~azure.mgmt.servicebus.v2021_11_01.models.SystemData :ivar size_in_bytes: Size of the topic, in bytes. - :vartype size_in_bytes: long + :vartype size_in_bytes: int :ivar created_at: Exact time the message was created. :vartype created_at: ~datetime.datetime :ivar updated_at: The exact time the message was updated. @@ -2766,7 +2662,7 @@ class SBTopic(ProxyResource): :vartype max_size_in_megabytes: int :ivar max_message_size_in_kilobytes: Maximum size (in KB) of the message payload that can be accepted by the topic. This property is only used in Premium today and default is 1024. - :vartype max_message_size_in_kilobytes: long + :vartype max_message_size_in_kilobytes: int :ivar requires_duplicate_detection: Value indicating if this topic requires duplicate detection. :vartype requires_duplicate_detection: bool @@ -2778,7 +2674,7 @@ class SBTopic(ProxyResource): :vartype enable_batched_operations: bool :ivar status: Enumerates the possible values for the status of a messaging entity. Known values are: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", "Creating", - "Deleting", "Renaming", "Unknown". + "Deleting", "Renaming", and "Unknown". :vartype status: str or ~azure.mgmt.servicebus.v2021_11_01.models.EntityStatus :ivar support_ordering: Value that indicates whether the topic supports ordering. :vartype support_ordering: bool @@ -2794,42 +2690,45 @@ class SBTopic(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'readonly': True}, - 'system_data': {'readonly': True}, - 'size_in_bytes': {'readonly': True}, - 'created_at': {'readonly': True}, - 'updated_at': {'readonly': True}, - 'accessed_at': {'readonly': True}, - 'subscription_count': {'readonly': True}, - 'count_details': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"readonly": True}, + "system_data": {"readonly": True}, + "size_in_bytes": {"readonly": True}, + "created_at": {"readonly": True}, + "updated_at": {"readonly": True}, + "accessed_at": {"readonly": True}, + "subscription_count": {"readonly": True}, + "count_details": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'size_in_bytes': {'key': 'properties.sizeInBytes', 'type': 'long'}, - 'created_at': {'key': 'properties.createdAt', 'type': 'iso-8601'}, - 'updated_at': {'key': 'properties.updatedAt', 'type': 'iso-8601'}, - 'accessed_at': {'key': 'properties.accessedAt', 'type': 'iso-8601'}, - 'subscription_count': {'key': 'properties.subscriptionCount', 'type': 'int'}, - 'count_details': {'key': 'properties.countDetails', 'type': 'MessageCountDetails'}, - 'default_message_time_to_live': {'key': 'properties.defaultMessageTimeToLive', 'type': 'duration'}, - 'max_size_in_megabytes': {'key': 'properties.maxSizeInMegabytes', 'type': 'int'}, - 'max_message_size_in_kilobytes': {'key': 'properties.maxMessageSizeInKilobytes', 'type': 'long'}, - 'requires_duplicate_detection': {'key': 'properties.requiresDuplicateDetection', 'type': 'bool'}, - 'duplicate_detection_history_time_window': {'key': 'properties.duplicateDetectionHistoryTimeWindow', 'type': 'duration'}, - 'enable_batched_operations': {'key': 'properties.enableBatchedOperations', 'type': 'bool'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'support_ordering': {'key': 'properties.supportOrdering', 'type': 'bool'}, - 'auto_delete_on_idle': {'key': 'properties.autoDeleteOnIdle', 'type': 'duration'}, - 'enable_partitioning': {'key': 'properties.enablePartitioning', 'type': 'bool'}, - 'enable_express': {'key': 'properties.enableExpress', 'type': 'bool'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "size_in_bytes": {"key": "properties.sizeInBytes", "type": "int"}, + "created_at": {"key": "properties.createdAt", "type": "iso-8601"}, + "updated_at": {"key": "properties.updatedAt", "type": "iso-8601"}, + "accessed_at": {"key": "properties.accessedAt", "type": "iso-8601"}, + "subscription_count": {"key": "properties.subscriptionCount", "type": "int"}, + "count_details": {"key": "properties.countDetails", "type": "MessageCountDetails"}, + "default_message_time_to_live": {"key": "properties.defaultMessageTimeToLive", "type": "duration"}, + "max_size_in_megabytes": {"key": "properties.maxSizeInMegabytes", "type": "int"}, + "max_message_size_in_kilobytes": {"key": "properties.maxMessageSizeInKilobytes", "type": "int"}, + "requires_duplicate_detection": {"key": "properties.requiresDuplicateDetection", "type": "bool"}, + "duplicate_detection_history_time_window": { + "key": "properties.duplicateDetectionHistoryTimeWindow", + "type": "duration", + }, + "enable_batched_operations": {"key": "properties.enableBatchedOperations", "type": "bool"}, + "status": {"key": "properties.status", "type": "str"}, + "support_ordering": {"key": "properties.supportOrdering", "type": "bool"}, + "auto_delete_on_idle": {"key": "properties.autoDeleteOnIdle", "type": "duration"}, + "enable_partitioning": {"key": "properties.enablePartitioning", "type": "bool"}, + "enable_express": {"key": "properties.enableExpress", "type": "bool"}, } def __init__( @@ -2858,7 +2757,7 @@ def __init__( :paramtype max_size_in_megabytes: int :keyword max_message_size_in_kilobytes: Maximum size (in KB) of the message payload that can be accepted by the topic. This property is only used in Premium today and default is 1024. - :paramtype max_message_size_in_kilobytes: long + :paramtype max_message_size_in_kilobytes: int :keyword requires_duplicate_detection: Value indicating if this topic requires duplicate detection. :paramtype requires_duplicate_detection: bool @@ -2870,7 +2769,7 @@ def __init__( :paramtype enable_batched_operations: bool :keyword status: Enumerates the possible values for the status of a messaging entity. Known values are: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", "Creating", - "Deleting", "Renaming", "Unknown". + "Deleting", "Renaming", and "Unknown". :paramtype status: str or ~azure.mgmt.servicebus.v2021_11_01.models.EntityStatus :keyword support_ordering: Value that indicates whether the topic supports ordering. :paramtype support_ordering: bool @@ -2884,7 +2783,7 @@ def __init__( topic holds a message in memory temporarily before writing it to persistent storage. :paramtype enable_express: bool """ - super(SBTopic, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.size_in_bytes = None self.created_at = None @@ -2905,7 +2804,7 @@ def __init__( self.enable_express = enable_express -class SBTopicListResult(msrest.serialization.Model): +class SBTopicListResult(_serialization.Model): """The response to the List Topics operation. :ivar value: Result of the List Topics operation. @@ -2916,17 +2815,11 @@ class SBTopicListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[SBTopic]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SBTopic]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["_models.SBTopic"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.SBTopic"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: Result of the List Topics operation. :paramtype value: list[~azure.mgmt.servicebus.v2021_11_01.models.SBTopic] @@ -2934,12 +2827,12 @@ def __init__( list of topics. :paramtype next_link: str """ - super(SBTopicListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class SqlFilter(msrest.serialization.Model): +class SqlFilter(_serialization.Model): """Represents a filter which is a composition of an expression and an action that is executed in the pub/sub pipeline. :ivar sql_expression: The SQL expression. e.g. MyProperty='ABC'. @@ -2953,9 +2846,9 @@ class SqlFilter(msrest.serialization.Model): """ _attribute_map = { - 'sql_expression': {'key': 'sqlExpression', 'type': 'str'}, - 'compatibility_level': {'key': 'compatibilityLevel', 'type': 'int'}, - 'requires_preprocessing': {'key': 'requiresPreprocessing', 'type': 'bool'}, + "sql_expression": {"key": "sqlExpression", "type": "str"}, + "compatibility_level": {"key": "compatibilityLevel", "type": "int"}, + "requires_preprocessing": {"key": "requiresPreprocessing", "type": "bool"}, } def __init__( @@ -2963,7 +2856,7 @@ def __init__( *, sql_expression: Optional[str] = None, compatibility_level: Optional[int] = None, - requires_preprocessing: Optional[bool] = True, + requires_preprocessing: bool = True, **kwargs ): """ @@ -2976,7 +2869,7 @@ def __init__( preprocessing. :paramtype requires_preprocessing: bool """ - super(SqlFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.sql_expression = sql_expression self.compatibility_level = compatibility_level self.requires_preprocessing = requires_preprocessing @@ -2996,9 +2889,9 @@ class SqlRuleAction(Action): """ _attribute_map = { - 'sql_expression': {'key': 'sqlExpression', 'type': 'str'}, - 'compatibility_level': {'key': 'compatibilityLevel', 'type': 'int'}, - 'requires_preprocessing': {'key': 'requiresPreprocessing', 'type': 'bool'}, + "sql_expression": {"key": "sqlExpression", "type": "str"}, + "compatibility_level": {"key": "compatibilityLevel", "type": "int"}, + "requires_preprocessing": {"key": "requiresPreprocessing", "type": "bool"}, } def __init__( @@ -3006,7 +2899,7 @@ def __init__( *, sql_expression: Optional[str] = None, compatibility_level: Optional[int] = None, - requires_preprocessing: Optional[bool] = True, + requires_preprocessing: bool = True, **kwargs ): """ @@ -3019,66 +2912,66 @@ def __init__( preprocessing. :paramtype requires_preprocessing: bool """ - super(SqlRuleAction, self).__init__(sql_expression=sql_expression, compatibility_level=compatibility_level, requires_preprocessing=requires_preprocessing, **kwargs) + super().__init__( + sql_expression=sql_expression, + compatibility_level=compatibility_level, + requires_preprocessing=requires_preprocessing, + **kwargs + ) -class Subnet(msrest.serialization.Model): +class Subnet(_serialization.Model): """Properties supplied for Subnet. All required parameters must be populated in order to send to Azure. - :ivar id: Required. Resource ID of Virtual Network Subnet. + :ivar id: Resource ID of Virtual Network Subnet. Required. :vartype id: str """ _validation = { - 'id': {'required': True}, + "id": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - *, - id: str, - **kwargs - ): + def __init__(self, *, id: str, **kwargs): # pylint: disable=redefined-builtin """ - :keyword id: Required. Resource ID of Virtual Network Subnet. + :keyword id: Resource ID of Virtual Network Subnet. Required. :paramtype id: str """ - super(Subnet, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id -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. Known values are: - "User", "Application", "ManagedIdentity", "Key". + "User", "Application", "ManagedIdentity", and "Key". :vartype created_by_type: str or ~azure.mgmt.servicebus.v2021_11_01.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", "Key". + are: "User", "Application", "ManagedIdentity", and "Key". :vartype last_modified_by_type: str or ~azure.mgmt.servicebus.v2021_11_01.models.CreatedByType :ivar last_modified_at: The type of identity that last modified the resource. :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__( @@ -3096,20 +2989,20 @@ def __init__( :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", "Key". + "User", "Application", "ManagedIdentity", and "Key". :paramtype created_by_type: str or ~azure.mgmt.servicebus.v2021_11_01.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", "Key". + values are: "User", "Application", "ManagedIdentity", and "Key". :paramtype last_modified_by_type: str or ~azure.mgmt.servicebus.v2021_11_01.models.CreatedByType :keyword last_modified_at: The type of identity that last modified the resource. :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 @@ -3118,7 +3011,7 @@ def __init__( self.last_modified_at = last_modified_at -class UserAssignedIdentity(msrest.serialization.Model): +class UserAssignedIdentity(_serialization.Model): """Recognized Dictionary value. Variables are only populated by the server, and will be ignored when sending a request. @@ -3130,27 +3023,23 @@ class UserAssignedIdentity(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(UserAssignedIdentity, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.principal_id = None self.client_id = None -class UserAssignedIdentityProperties(msrest.serialization.Model): +class UserAssignedIdentityProperties(_serialization.Model): """UserAssignedIdentityProperties. :ivar user_assigned_identity: ARM ID of user Identity selected for encryption. @@ -3158,18 +3047,13 @@ class UserAssignedIdentityProperties(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: ARM ID of user Identity selected for encryption. :paramtype user_assigned_identity: str """ - super(UserAssignedIdentityProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.user_assigned_identity = user_assigned_identity diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/models/_patch.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/models/_patch.py index 0ad201a8c586e..f7dd32510333d 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/models/_patch.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/models/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/models/_service_bus_management_client_enums.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/models/_service_bus_management_client_enums.py index 33112c2ab17d4..ce716a0147196 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/models/_service_bus_management_client_enums.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/models/_service_bus_management_client_enums.py @@ -11,30 +11,31 @@ class AccessRights(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """AccessRights.""" MANAGE = "Manage" SEND = "Send" LISTEN = "Listen" + class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of identity that created the resource. - """ + """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 - """ + """Default Action for Network Rule Set.""" ALLOW = "Allow" DENY = "Deny" + class EndPointProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Provisioning state of the Private Endpoint Connection. - """ + """Provisioning state of the Private Endpoint Connection.""" CREATING = "Creating" UPDATING = "Updating" @@ -43,9 +44,9 @@ class EndPointProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): CANCELED = "Canceled" FAILED = "Failed" + class EntityStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Entity status. - """ + """Entity status.""" ACTIVE = "Active" DISABLED = "Disabled" @@ -57,92 +58,96 @@ class EntityStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): RENAMING = "Renaming" UNKNOWN = "Unknown" + class FilterType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Rule filter types - """ + """Rule filter types.""" SQL_FILTER = "SqlFilter" CORRELATION_FILTER = "CorrelationFilter" + class KeyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The access key to regenerate. - """ + """The access key to regenerate.""" PRIMARY_KEY = "PrimaryKey" SECONDARY_KEY = "SecondaryKey" + class ManagedServiceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Type of managed service identity. - """ + """Type of managed service identity.""" SYSTEM_ASSIGNED = "SystemAssigned" USER_ASSIGNED = "UserAssigned" SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" NONE = "None" + class MigrationConfigurationName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """MigrationConfigurationName.""" _DEFAULT = "$default" + class NetworkRuleIPAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The IP Filter Action - """ + """The IP Filter Action.""" ALLOW = "Allow" + class PrivateLinkConnectionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Status of the connection. - """ + """Status of the connection.""" PENDING = "Pending" APPROVED = "Approved" REJECTED = "Rejected" DISCONNECTED = "Disconnected" + class ProvisioningStateDR(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Provisioning state of the Alias(Disaster Recovery configuration) - possible values 'Accepted' - or 'Succeeded' or 'Failed' + or 'Succeeded' or 'Failed'. """ ACCEPTED = "Accepted" SUCCEEDED = "Succeeded" FAILED = "Failed" + class PublicNetworkAccessFlag(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """This determines if traffic is allowed over public network. By default it is enabled. - """ + """This determines if traffic is allowed over public network. By default it is enabled.""" ENABLED = "Enabled" DISABLED = "Disabled" + class RoleDisasterRecovery(str, Enum, metaclass=CaseInsensitiveEnumMeta): """role of namespace in GEO DR - possible values 'Primary' or 'PrimaryNotReplicating' or - 'Secondary' + 'Secondary'. """ PRIMARY = "Primary" PRIMARY_NOT_REPLICATING = "PrimaryNotReplicating" SECONDARY = "Secondary" + class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Name of this SKU. - """ + """Name of this SKU.""" BASIC = "Basic" STANDARD = "Standard" PREMIUM = "Premium" + class SkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The billing tier of this particular SKU. - """ + """The billing tier of this particular SKU.""" BASIC = "Basic" STANDARD = "Standard" PREMIUM = "Premium" + class UnavailableReason(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the reason for the unavailability of the service. - """ + """Specifies the reason for the unavailability of the service.""" NONE = "None" INVALID_NAME = "InvalidName" diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/operations/__init__.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/operations/__init__.py index 5559ccd3746c6..e5431803c533c 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/operations/__init__.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/operations/__init__.py @@ -18,19 +18,20 @@ from ._subscriptions_operations import SubscriptionsOperations from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'NamespacesOperations', - 'PrivateEndpointConnectionsOperations', - 'PrivateLinkResourcesOperations', - 'Operations', - 'DisasterRecoveryConfigsOperations', - 'MigrationConfigsOperations', - 'QueuesOperations', - 'TopicsOperations', - 'RulesOperations', - 'SubscriptionsOperations', + "NamespacesOperations", + "PrivateEndpointConnectionsOperations", + "PrivateLinkResourcesOperations", + "Operations", + "DisasterRecoveryConfigsOperations", + "MigrationConfigsOperations", + "QueuesOperations", + "TopicsOperations", + "RulesOperations", + "SubscriptionsOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/operations/_disaster_recovery_configs_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/operations/_disaster_recovery_configs_operations.py index a669afa805d6b..394faeb4b0d37 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/operations/_disaster_recovery_configs_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/operations/_disaster_recovery_configs_operations.py @@ -6,11 +6,18 @@ # 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 msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,298 +27,261 @@ 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') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +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, - namespace_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_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-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( - resource_group_name: str, - namespace_name: str, - alias: str, - subscription_id: str, - *, - json: Optional[_models.ArmDisasterRecovery] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_name: str, alias: 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-11-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: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "alias": _SERIALIZER.url("alias", alias, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "alias": _SERIALIZER.url("alias", alias, "str", max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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') + _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, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - namespace_name: str, - alias: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, alias: 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-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "alias": _SERIALIZER.url("alias", alias, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "alias": _SERIALIZER.url("alias", alias, "str", max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - namespace_name: str, - alias: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, alias: 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-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "alias": _SERIALIZER.url("alias", alias, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "alias": _SERIALIZER.url("alias", alias, "str", max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_break_pairing_request( - resource_group_name: str, - namespace_name: str, - alias: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, alias: 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-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/breakPairing") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/breakPairing", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "alias": _SERIALIZER.url("alias", alias, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "alias": _SERIALIZER.url("alias", alias, "str", max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_fail_over_request( - resource_group_name: str, - namespace_name: str, - alias: str, - subscription_id: str, - *, - json: Optional[_models.FailoverProperties] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_name: str, alias: 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-11-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: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/failover") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/failover", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "alias": _SERIALIZER.url("alias", alias, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "alias": _SERIALIZER.url("alias", alias, "str", max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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') + _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, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_authorization_rules_request( - resource_group_name: str, - namespace_name: str, - alias: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, alias: 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-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "alias": _SERIALIZER.url("alias", alias, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "alias": _SERIALIZER.url("alias", alias, "str", max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_authorization_rule_request( @@ -325,34 +295,35 @@ def build_get_authorization_rule_request( _headers = case_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-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules/{authorizationRuleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "alias": _SERIALIZER.url("alias", alias, 'str', max_length=50, min_length=1), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "alias": _SERIALIZER.url("alias", alias, "str", max_length=50, min_length=1), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_keys_request( @@ -366,79 +337,72 @@ def build_list_keys_request( _headers = case_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-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules/{authorizationRuleName}/listKeys") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules/{authorizationRuleName}/listKeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "alias": _SERIALIZER.url("alias", alias, 'str', max_length=50, min_length=1), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "alias": _SERIALIZER.url("alias", alias, "str", max_length=50, min_length=1), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_check_name_availability_request( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - *, - json: Optional[_models.CheckNameAvailability] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_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-11-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: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/CheckNameAvailability") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/CheckNameAvailability", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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, - 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 DisasterRecoveryConfigsOperations: """ @@ -459,65 +423,66 @@ def __init__(self, *args, **kwargs): 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, - namespace_name: str, - **kwargs: Any - ) -> Iterable[_models.ArmDisasterRecoveryListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> Iterable["_models.ArmDisasterRecovery"]: """Gets all Alias(Disaster Recovery configurations). - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ArmDisasterRecoveryListResult or the result of - cls(response) + :return: An iterator like instance of either ArmDisasterRecovery or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.ArmDisasterRecoveryListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.ArmDisasterRecovery] + :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', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ArmDisasterRecoveryListResult] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + cls: ClsType[_models.ArmDisasterRecoveryListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -525,16 +490,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("ArmDisasterRecoveryListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -545,49 +508,124 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs" + } - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, namespace_name: str, alias: str, parameters: _models.ArmDisasterRecovery, + *, + content_type: str = "application/json", **kwargs: Any ) -> Optional[_models.ArmDisasterRecovery]: """Creates or updates a new Alias(Disaster Recovery configuration). - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: str :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). + Required. :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.ArmDisasterRecovery + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ArmDisasterRecovery or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.ArmDisasterRecovery or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + alias: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> Optional[_models.ArmDisasterRecovery]: + """Creates or updates a new Alias(Disaster Recovery configuration). + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: str + :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). + Required. + :type 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: ArmDisasterRecovery, or the result of cls(response) + :return: ArmDisasterRecovery or None or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.ArmDisasterRecovery or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + alias: str, + parameters: Union[_models.ArmDisasterRecovery, IO], + **kwargs: Any + ) -> Optional[_models.ArmDisasterRecovery]: + """Creates or updates a new Alias(Disaster Recovery configuration). + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: str + :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). Is + either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.ArmDisasterRecovery 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: ArmDisasterRecovery or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.ArmDisasterRecovery or None + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ArmDisasterRecovery]] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.ArmDisasterRecovery]] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'ArmDisasterRecovery') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ArmDisasterRecovery") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -597,18 +635,18 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - 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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -618,67 +656,65 @@ def create_or_update( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ArmDisasterRecovery', pipeline_response) + deserialized = self._deserialize("ArmDisasterRecovery", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}"} # type: ignore - + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}" + } @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - alias: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, alias: str, **kwargs: Any ) -> None: """Deletes an Alias(Disaster Recovery configuration). - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: 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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, alias=alias, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -689,60 +725,58 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}"} # type: ignore - + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}" + } @distributed_trace def get( - self, - resource_group_name: str, - namespace_name: str, - alias: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, alias: str, **kwargs: Any ) -> _models.ArmDisasterRecovery: """Retrieves Alias(Disaster Recovery configuration) for primary or secondary namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ArmDisasterRecovery, or the result of cls(response) + :return: ArmDisasterRecovery or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.ArmDisasterRecovery - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ArmDisasterRecovery] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + cls: ClsType[_models.ArmDisasterRecovery] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, alias=alias, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -750,68 +784,66 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ArmDisasterRecovery', pipeline_response) + deserialized = self._deserialize("ArmDisasterRecovery", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}" + } @distributed_trace def break_pairing( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - alias: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, alias: str, **kwargs: Any ) -> None: """This operation disables the Disaster Recovery and stops replicating changes from primary to secondary namespaces. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: 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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_break_pairing_request( resource_group_name=resource_group_name, namespace_name=namespace_name, alias=alias, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.break_pairing.metadata['url'], + template_url=self.break_pairing.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -822,50 +854,125 @@ def break_pairing( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - break_pairing.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/breakPairing"} # type: ignore - + break_pairing.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/breakPairing" + } - @distributed_trace + @overload def fail_over( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, alias: str, parameters: Optional[_models.FailoverProperties] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> None: """Invokes GEO DR failover and reconfigure the alias to point to the secondary namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: str :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). Default value is None. :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.FailoverProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default 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: + """ + + @overload + def fail_over( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + namespace_name: str, + alias: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Invokes GEO DR failover and reconfigure the alias to point to the secondary namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: str + :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). + Default value is None. + :type 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: 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: + """ + + @distributed_trace + def fail_over( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + namespace_name: str, + alias: str, + parameters: Optional[Union[_models.FailoverProperties, IO]] = None, + **kwargs: Any + ) -> None: + """Invokes GEO DR failover and reconfigure the alias to point to the secondary namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: str + :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). Is + either a model type or a IO type. Default value is None. + :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.FailoverProperties 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: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) - if parameters is not None: - _json = self._serialize.body(parameters, 'FailoverProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "FailoverProperties") + else: + _json = None request = build_fail_over_request( resource_group_name=resource_group_name, @@ -875,18 +982,18 @@ def fail_over( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, json=_json, - template_url=self.fail_over.metadata['url'], + content=_content, + template_url=self.fail_over.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -897,72 +1004,73 @@ def fail_over( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - fail_over.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/failover"} # type: ignore - + fail_over.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/failover" + } @distributed_trace def list_authorization_rules( - self, - resource_group_name: str, - namespace_name: str, - alias: str, - **kwargs: Any - ) -> Iterable[_models.SBAuthorizationRuleListResult]: + self, resource_group_name: str, namespace_name: str, alias: str, **kwargs: Any + ) -> Iterable["_models.SBAuthorizationRule"]: """Gets the authorization rules for a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of - cls(response) + :return: An iterator like instance of either SBAuthorizationRule or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.SBAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.SBAuthorizationRule] + :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', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRuleListResult] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + cls: ClsType[_models.SBAuthorizationRuleListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_authorization_rules_request( resource_group_name=resource_group_name, namespace_name=namespace_name, alias=alias, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_authorization_rules.metadata['url'], + template_url=self.list_authorization_rules.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_authorization_rules_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - alias=alias, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -970,16 +1078,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("SBAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -990,48 +1096,45 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_authorization_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules"} # type: ignore + list_authorization_rules.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules" + } @distributed_trace def get_authorization_rule( - self, - resource_group_name: str, - namespace_name: str, - alias: str, - authorization_rule_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, alias: str, authorization_rule_name: str, **kwargs: Any ) -> _models.SBAuthorizationRule: """Gets an authorization rule for a namespace by rule name. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + cls: ClsType[_models.SBAuthorizationRule] = kwargs.pop("cls", None) - request = build_get_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -1039,18 +1142,17 @@ def get_authorization_rule( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_authorization_rule.metadata['url'], + template_url=self.get_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1058,52 +1160,50 @@ def get_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules/{authorizationRuleName}"} # type: ignore - + get_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules/{authorizationRuleName}" + } @distributed_trace def list_keys( - self, - resource_group_name: str, - namespace_name: str, - alias: str, - authorization_rule_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, alias: str, authorization_rule_name: str, **kwargs: Any ) -> _models.AccessKeys: """Gets the primary and secondary connection strings for the namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + cls: ClsType[_models.AccessKeys] = kwargs.pop("cls", None) - request = build_list_keys_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -1111,18 +1211,17 @@ def list_keys( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata['url'], + 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 + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1130,50 +1229,118 @@ def list_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + deserialized = self._deserialize("AccessKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules/{authorizationRuleName}/listKeys"} # type: ignore - + list_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules/{authorizationRuleName}/listKeys" + } - @distributed_trace + @overload def check_name_availability( self, resource_group_name: str, namespace_name: str, parameters: _models.CheckNameAvailability, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Check the give namespace name availability. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: Parameters to check availability of the given namespace name. + :param parameters: Parameters to check availability of the given namespace name. Required. :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.CheckNameAvailability + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckNameAvailabilityResult or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters to check availability of the given namespace name. Required. + :type 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: CheckNameAvailabilityResult, or the result of cls(response) + :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.CheckNameAvailabilityResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_name_availability( + self, + resource_group_name: str, + namespace_name: str, + parameters: Union[_models.CheckNameAvailability, IO], + **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters to check availability of the given namespace name. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.CheckNameAvailability 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: CheckNameAvailabilityResult or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.CheckNameAvailabilityResult] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CheckNameAvailabilityResult] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'CheckNameAvailability') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "CheckNameAvailability") request = build_check_name_availability_request( resource_group_name=resource_group_name, @@ -1182,18 +1349,18 @@ def check_name_availability( 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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1201,12 +1368,13 @@ def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) + deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/CheckNameAvailability"} # type: ignore - + check_name_availability.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/CheckNameAvailability" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/operations/_migration_configs_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/operations/_migration_configs_operations.py index fed06161b0b7e..2a00aeedff952 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/operations/_migration_configs_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/operations/_migration_configs_operations.py @@ -6,11 +6,18 @@ # 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, Union, cast - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -22,251 +29,245 @@ 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') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +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, - namespace_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_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-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_and_start_migration_request_initial( +def build_create_and_start_migration_request( resource_group_name: str, namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], + config_name: Union[str, _models.MigrationConfigurationName], subscription_id: str, - *, - json: Optional[_models.MigrationConfigProperties] = None, - content: Any = 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', "2021-11-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: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "configName": _SERIALIZER.url("config_name", config_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "configName": _SERIALIZER.url("config_name", config_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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') + _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, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( resource_group_name: str, namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], + config_name: Union[str, _models.MigrationConfigurationName], 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-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "configName": _SERIALIZER.url("config_name", config_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "configName": _SERIALIZER.url("config_name", config_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( resource_group_name: str, namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], + config_name: Union[str, _models.MigrationConfigurationName], 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-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "configName": _SERIALIZER.url("config_name", config_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "configName": _SERIALIZER.url("config_name", config_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_complete_migration_request( resource_group_name: str, namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], + config_name: Union[str, _models.MigrationConfigurationName], 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-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/upgrade") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/upgrade", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "configName": _SERIALIZER.url("config_name", config_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "configName": _SERIALIZER.url("config_name", config_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_revert_request( resource_group_name: str, namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], + config_name: Union[str, _models.MigrationConfigurationName], 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-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/revert") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/revert", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "configName": _SERIALIZER.url("config_name", config_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "configName": _SERIALIZER.url("config_name", config_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class MigrationConfigsOperations: """ @@ -287,65 +288,67 @@ def __init__(self, *args, **kwargs): 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, - namespace_name: str, - **kwargs: Any - ) -> Iterable[_models.MigrationConfigListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> Iterable["_models.MigrationConfigProperties"]: """Gets all migrationConfigurations. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MigrationConfigListResult or the result of + :return: An iterator like instance of either MigrationConfigProperties or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.MigrationConfigListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.MigrationConfigProperties] + :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', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MigrationConfigListResult] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + cls: ClsType[_models.MigrationConfigListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -353,16 +356,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("MigrationConfigListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -373,35 +374,44 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations" + } def _create_and_start_migration_initial( self, resource_group_name: str, namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], - parameters: _models.MigrationConfigProperties, + config_name: Union[str, _models.MigrationConfigurationName], + parameters: Union[_models.MigrationConfigProperties, IO], **kwargs: Any ) -> Optional[_models.MigrationConfigProperties]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.MigrationConfigProperties]] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.MigrationConfigProperties]] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'MigrationConfigProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "MigrationConfigProperties") - request = build_create_and_start_migration_request_initial( + request = build_create_and_start_migration_request( resource_group_name=resource_group_name, namespace_name=namespace_name, config_name=config_name, @@ -409,56 +419,63 @@ def _create_and_start_migration_initial( api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_and_start_migration_initial.metadata['url'], + content=_content, + template_url=self._create_and_start_migration_initial.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('MigrationConfigProperties', pipeline_response) + deserialized = self._deserialize("MigrationConfigProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_and_start_migration_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}"} # type: ignore - + _create_and_start_migration_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}" + } - @distributed_trace + @overload def begin_create_and_start_migration( self, resource_group_name: str, namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], + config_name: Union[str, _models.MigrationConfigurationName], parameters: _models.MigrationConfigProperties, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.MigrationConfigProperties]: """Creates Migration configuration and starts migration of entities from Standard to Premium namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :type config_name: str or ~azure.mgmt.servicebus.v2021_11_01.models.MigrationConfigurationName - :param parameters: Parameters required to create Migration Configuration. + :param parameters: Parameters required to create Migration Configuration. Required. :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.MigrationConfigProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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 @@ -471,113 +488,188 @@ def begin_create_and_start_migration( of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.servicebus.v2021_11_01.models.MigrationConfigProperties] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_and_start_migration( + self, + resource_group_name: str, + namespace_name: str, + config_name: Union[str, _models.MigrationConfigurationName], + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.MigrationConfigProperties]: + """Creates Migration configuration and starts migration of entities from Standard to Premium + namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param config_name: The configuration name. Should always be "$default". "$default" Required. + :type config_name: str or ~azure.mgmt.servicebus.v2021_11_01.models.MigrationConfigurationName + :param parameters: Parameters required to create Migration Configuration. Required. + :type 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 + :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 MigrationConfigProperties or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.servicebus.v2021_11_01.models.MigrationConfigProperties] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_and_start_migration( + self, + resource_group_name: str, + namespace_name: str, + config_name: Union[str, _models.MigrationConfigurationName], + parameters: Union[_models.MigrationConfigProperties, IO], + **kwargs: Any + ) -> LROPoller[_models.MigrationConfigProperties]: + """Creates Migration configuration and starts migration of entities from Standard to Premium + namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param config_name: The configuration name. Should always be "$default". "$default" Required. + :type config_name: str or ~azure.mgmt.servicebus.v2021_11_01.models.MigrationConfigurationName + :param parameters: Parameters required to create Migration Configuration. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.MigrationConfigProperties 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 MigrationConfigProperties or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.servicebus.v2021_11_01.models.MigrationConfigProperties] + :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-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.MigrationConfigProperties] - 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] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.MigrationConfigProperties] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._create_and_start_migration_initial( # type: ignore + raw_result = self._create_and_start_migration_initial( resource_group_name=resource_group_name, namespace_name=namespace_name, config_name=config_name, parameters=parameters, 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): - deserialized = self._deserialize('MigrationConfigProperties', pipeline_response) + deserialized = self._deserialize("MigrationConfigProperties", 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 + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create_and_start_migration.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}"} # type: ignore + begin_create_and_start_migration.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}" + } @distributed_trace def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], + config_name: Union[str, _models.MigrationConfigurationName], **kwargs: Any ) -> None: """Deletes a MigrationConfiguration. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :type config_name: str or ~azure.mgmt.servicebus.v2021_11_01.models.MigrationConfigurationName :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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, config_name=config_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -588,60 +680,62 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}"} # type: ignore - + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}" + } @distributed_trace def get( self, resource_group_name: str, namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], + config_name: Union[str, _models.MigrationConfigurationName], **kwargs: Any ) -> _models.MigrationConfigProperties: """Retrieves Migration Config. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :type config_name: str or ~azure.mgmt.servicebus.v2021_11_01.models.MigrationConfigurationName :keyword callable cls: A custom type or function that will be passed the direct response - :return: MigrationConfigProperties, or the result of cls(response) + :return: MigrationConfigProperties or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.MigrationConfigProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MigrationConfigProperties] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + cls: ClsType[_models.MigrationConfigProperties] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, config_name=config_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -649,69 +743,71 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('MigrationConfigProperties', pipeline_response) + deserialized = self._deserialize("MigrationConfigProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}" + } @distributed_trace def complete_migration( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], + config_name: Union[str, _models.MigrationConfigurationName], **kwargs: Any ) -> None: """This operation Completes Migration of entities by pointing the connection strings to Premium namespace and any entities created after the operation will be under Premium Namespace. CompleteMigration operation will fail when entity migration is in-progress. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :type config_name: str or ~azure.mgmt.servicebus.v2021_11_01.models.MigrationConfigurationName :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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_complete_migration_request( resource_group_name=resource_group_name, namespace_name=namespace_name, config_name=config_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.complete_migration.metadata['url'], + template_url=self.complete_migration.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -722,60 +818,62 @@ def complete_migration( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - complete_migration.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/upgrade"} # type: ignore - + complete_migration.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/upgrade" + } @distributed_trace def revert( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], + config_name: Union[str, _models.MigrationConfigurationName], **kwargs: Any ) -> None: """This operation reverts Migration. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :type config_name: str or ~azure.mgmt.servicebus.v2021_11_01.models.MigrationConfigurationName :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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_revert_request( resource_group_name=resource_group_name, namespace_name=namespace_name, config_name=config_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.revert.metadata['url'], + template_url=self.revert.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -786,5 +884,6 @@ def revert( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - revert.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/revert"} # type: ignore - + revert.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/revert" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/operations/_namespaces_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/operations/_namespaces_operations.py index d6af66a8d3c80..5a247f9caec3f 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/operations/_namespaces_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/operations/_namespaces_operations.py @@ -6,11 +6,18 @@ # 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, Union, cast - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -22,651 +29,561 @@ 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') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +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, - **kwargs: Any -) -> HttpRequest: + +def build_list_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-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/namespaces") 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: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _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: + +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-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _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( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - *, - json: Optional[_models.SBNamespace] = None, - content: Any = None, - **kwargs: Any +def build_create_or_update_request( + resource_group_name: str, namespace_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-11-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: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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, - 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( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - **kwargs: Any +def build_delete_request( + resource_group_name: str, namespace_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-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_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-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _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, - namespace_name: str, - subscription_id: str, - *, - json: Optional[_models.SBNamespaceUpdateParameters] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_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-11-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: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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, - 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_create_or_update_network_rule_set_request( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - *, - json: Optional[_models.NetworkRuleSet] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_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-11-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: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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, - 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_get_network_rule_set_request( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_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-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_network_rule_sets_request( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_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-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_authorization_rules_request( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_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-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_authorization_rule_request( - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - subscription_id: str, - *, - json: Optional[_models.SBAuthorizationRule] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_name: str, authorization_rule_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-11-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: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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, - 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_authorization_rule_request( - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, authorization_rule_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-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_authorization_rule_request( - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, authorization_rule_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-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_keys_request( - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, authorization_rule_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-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/listKeys") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/listKeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_regenerate_keys_request( - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - subscription_id: str, - *, - json: Optional[_models.RegenerateAccessKeyParameters] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_name: str, authorization_rule_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-11-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: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/regenerateKeys") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/regenerateKeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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, - 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_check_name_availability_request( - subscription_id: str, - *, - json: Optional[_models.CheckNameAvailability] = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: + +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-11-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: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/CheckNameAvailability") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/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: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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, - 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 NamespacesOperations: """ @@ -687,55 +604,57 @@ def __init__(self, *args, **kwargs): 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.SBNamespaceListResult]: + def list(self, **kwargs: Any) -> Iterable["_models.SBNamespace"]: """Gets all the available namespaces within the subscription, irrespective of the resource groups. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBNamespaceListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.SBNamespaceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either SBNamespace or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.SBNamespace] + :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', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBNamespaceListResult] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + cls: ClsType[_models.SBNamespaceListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -743,16 +662,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("SBNamespaceListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -763,65 +680,64 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/namespaces"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/namespaces"} @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable[_models.SBNamespaceListResult]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.SBNamespace"]: """Gets the available namespaces within a resource group. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. 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 SBNamespaceListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.SBNamespaceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either SBNamespace or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.SBNamespace] + :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', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBNamespaceListResult] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + cls: ClsType[_models.SBNamespaceListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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'], + 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 + request.url = self._client.format_url(request.url) else: - - 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=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -829,16 +745,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("SBNamespaceListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -849,90 +763,102 @@ 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.ServiceBus/namespaces"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces" + } def _create_or_update_initial( - self, - resource_group_name: str, - namespace_name: str, - parameters: _models.SBNamespace, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, parameters: Union[_models.SBNamespace, IO], **kwargs: Any ) -> Optional[_models.SBNamespace]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.SBNamespace]] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.SBNamespace]] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'SBNamespace') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBNamespace") - request = build_create_or_update_request_initial( + request = build_create_or_update_request( resource_group_name=resource_group_name, namespace_name=namespace_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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('SBNamespace', pipeline_response) + deserialized = self._deserialize("SBNamespace", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('SBNamespace', pipeline_response) + deserialized = self._deserialize("SBNamespace", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore - + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}" + } - @distributed_trace + @overload def begin_create_or_update( self, resource_group_name: str, namespace_name: str, parameters: _models.SBNamespace, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.SBNamespace]: """Creates or updates a service namespace. Once created, this namespace's resource manifest is immutable. This operation is idempotent. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: Parameters supplied to create a namespace resource. + :param parameters: Parameters supplied to create a namespace resource. Required. :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.SBNamespace + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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 @@ -944,121 +870,178 @@ def begin_create_or_update( :return: An instance of LROPoller that returns either SBNamespace or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.servicebus.v2021_11_01.models.SBNamespace] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.SBNamespace]: + """Creates or updates a service namespace. Once created, this namespace's resource manifest is + immutable. This operation is idempotent. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to create a namespace resource. Required. + :type 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 + :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 SBNamespace or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.servicebus.v2021_11_01.models.SBNamespace] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, resource_group_name: str, namespace_name: str, parameters: Union[_models.SBNamespace, IO], **kwargs: Any + ) -> LROPoller[_models.SBNamespace]: + """Creates or updates a service namespace. Once created, this namespace's resource manifest is + immutable. This operation is idempotent. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to create a namespace resource. Is either a model type + or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.SBNamespace 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 SBNamespace or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.servicebus.v2021_11_01.models.SBNamespace] + :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-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBNamespace] - 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] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SBNamespace] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._create_or_update_initial( # type: ignore + raw_result = self._create_or_update_initial( resource_group_name=resource_group_name, namespace_name=namespace_name, parameters=parameters, 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): - deserialized = self._deserialize('SBNamespace', pipeline_response) + deserialized = self._deserialize("SBNamespace", 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 + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}" + } def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, **kwargs: Any ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request_initial( + request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + 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 + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}" + } @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete(self, resource_group_name: str, namespace_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes an existing namespace. This operation also removes all associated resources under the namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_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. @@ -1070,103 +1053,94 @@ def begin_delete( # pylint: disable=inconsistent-return-statements 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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: 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] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, namespace_name=namespace_name, api_version=api_version, - 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 = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}" + } @distributed_trace - def get( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> _models.SBNamespace: + def get(self, resource_group_name: str, namespace_name: str, **kwargs: Any) -> _models.SBNamespace: """Gets a description for the specified namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBNamespace, or the result of cls(response) + :return: SBNamespace or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.SBNamespace - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBNamespace] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + cls: ClsType[_models.SBNamespace] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1174,51 +1148,121 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBNamespace', pipeline_response) + deserialized = self._deserialize("SBNamespace", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}" + } - @distributed_trace + @overload def update( self, resource_group_name: str, namespace_name: str, parameters: _models.SBNamespaceUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> Optional[_models.SBNamespace]: """Updates a service namespace. Once created, this namespace's resource manifest is immutable. This operation is idempotent. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: Parameters supplied to update a namespace resource. + :param parameters: Parameters supplied to update a namespace resource. Required. :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.SBNamespaceUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBNamespace or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.SBNamespace or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> Optional[_models.SBNamespace]: + """Updates a service namespace. Once created, this namespace's resource manifest is immutable. + This operation is idempotent. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to update a namespace resource. Required. + :type 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: SBNamespace or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.SBNamespace or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + namespace_name: str, + parameters: Union[_models.SBNamespaceUpdateParameters, IO], + **kwargs: Any + ) -> Optional[_models.SBNamespace]: + """Updates a service namespace. Once created, this namespace's resource manifest is immutable. + This operation is idempotent. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to update a namespace resource. Is either a model type + or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.SBNamespaceUpdateParameters 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: SBNamespace, or the result of cls(response) + :return: SBNamespace or None or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.SBNamespace or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.SBNamespace]] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.SBNamespace]] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'SBNamespaceUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBNamespaceUpdateParameters") request = build_update_request( resource_group_name=resource_group_name, @@ -1227,18 +1271,18 @@ def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -1248,53 +1292,120 @@ def update( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('SBNamespace', pipeline_response) + deserialized = self._deserialize("SBNamespace", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('SBNamespace', pipeline_response) + deserialized = self._deserialize("SBNamespace", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore - + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}" + } - @distributed_trace + @overload def create_or_update_network_rule_set( self, resource_group_name: str, namespace_name: str, parameters: _models.NetworkRuleSet, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.NetworkRuleSet: """Create or update NetworkRuleSet for a Namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: The Namespace IpFilterRule. + :param parameters: The Namespace IpFilterRule. Required. :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.NetworkRuleSet + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: NetworkRuleSet, or the result of cls(response) + :return: NetworkRuleSet or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.NetworkRuleSet - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_network_rule_set( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.NetworkRuleSet: + """Create or update NetworkRuleSet for a Namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: The Namespace IpFilterRule. Required. + :type 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: NetworkRuleSet or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.NetworkRuleSet + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update_network_rule_set( + self, + resource_group_name: str, + namespace_name: str, + parameters: Union[_models.NetworkRuleSet, IO], + **kwargs: Any + ) -> _models.NetworkRuleSet: + """Create or update NetworkRuleSet for a Namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: The Namespace IpFilterRule. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.NetworkRuleSet 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: NetworkRuleSet or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.NetworkRuleSet + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.NetworkRuleSet] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.NetworkRuleSet] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'NetworkRuleSet') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "NetworkRuleSet") request = build_create_or_update_network_rule_set_request( resource_group_name=resource_group_name, @@ -1303,18 +1414,18 @@ def create_or_update_network_rule_set( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_network_rule_set.metadata['url'], + content=_content, + template_url=self.create_or_update_network_rule_set.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1322,63 +1433,62 @@ def create_or_update_network_rule_set( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('NetworkRuleSet', pipeline_response) + deserialized = self._deserialize("NetworkRuleSet", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_network_rule_set.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default"} # type: ignore - + create_or_update_network_rule_set.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default" + } @distributed_trace def get_network_rule_set( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, **kwargs: Any ) -> _models.NetworkRuleSet: """Gets NetworkRuleSet for a Namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: NetworkRuleSet, or the result of cls(response) + :return: NetworkRuleSet or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.NetworkRuleSet - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.NetworkRuleSet] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + cls: ClsType[_models.NetworkRuleSet] = kwargs.pop("cls", None) - request = build_get_network_rule_set_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_network_rule_set.metadata['url'], + template_url=self.get_network_rule_set.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1386,74 +1496,76 @@ def get_network_rule_set( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('NetworkRuleSet', pipeline_response) + deserialized = self._deserialize("NetworkRuleSet", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_network_rule_set.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default"} # type: ignore - + get_network_rule_set.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default" + } @distributed_trace def list_network_rule_sets( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> Iterable[_models.NetworkRuleSetListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> Iterable["_models.NetworkRuleSet"]: """Gets list of NetworkRuleSet for a Namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either NetworkRuleSetListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.NetworkRuleSetListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either NetworkRuleSet or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.NetworkRuleSet] + :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', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.NetworkRuleSetListResult] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + cls: ClsType[_models.NetworkRuleSetListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_network_rule_sets_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_network_rule_sets.metadata['url'], + template_url=self.list_network_rule_sets.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_network_rule_sets_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -1461,16 +1573,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("NetworkRuleSetListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1481,70 +1591,72 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_network_rule_sets.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets"} # type: ignore + list_network_rule_sets.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets" + } @distributed_trace def list_authorization_rules( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> Iterable[_models.SBAuthorizationRuleListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> Iterable["_models.SBAuthorizationRule"]: """Gets the authorization rules for a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of - cls(response) + :return: An iterator like instance of either SBAuthorizationRule or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.SBAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.SBAuthorizationRule] + :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', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRuleListResult] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + cls: ClsType[_models.SBAuthorizationRuleListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_authorization_rules_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_authorization_rules.metadata['url'], + template_url=self.list_authorization_rules.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_authorization_rules_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -1552,16 +1664,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("SBAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1572,49 +1682,122 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_authorization_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules"} # type: ignore + list_authorization_rules.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules" + } - @distributed_trace + @overload def create_or_update_authorization_rule( self, resource_group_name: str, namespace_name: str, authorization_rule_name: str, parameters: _models.SBAuthorizationRule, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SBAuthorizationRule: """Creates or updates an authorization rule for a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: The shared access authorization rule. + :param parameters: The shared access authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.SBAuthorizationRule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBAuthorizationRule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates or updates an authorization rule for a namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Required. + :type 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: SBAuthorizationRule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: Union[_models.SBAuthorizationRule, IO], + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates or updates an authorization rule for a namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.SBAuthorizationRule 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: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SBAuthorizationRule] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'SBAuthorizationRule') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBAuthorizationRule") request = build_create_or_update_authorization_rule_request( resource_group_name=resource_group_name, @@ -1624,18 +1807,18 @@ def create_or_update_authorization_rule( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_authorization_rule.metadata['url'], + content=_content, + template_url=self.create_or_update_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1643,67 +1826,65 @@ def create_or_update_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}"} # type: ignore - + create_or_update_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}" + } @distributed_trace def delete_authorization_rule( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, authorization_rule_name: str, **kwargs: Any ) -> None: """Deletes a namespace authorization rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_authorization_rule.metadata['url'], + template_url=self.delete_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1714,60 +1895,58 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}"} # type: ignore - + delete_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}" + } @distributed_trace def get_authorization_rule( - self, - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, authorization_rule_name: str, **kwargs: Any ) -> _models.SBAuthorizationRule: """Gets an authorization rule for a namespace by rule name. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + cls: ClsType[_models.SBAuthorizationRule] = kwargs.pop("cls", None) - request = build_get_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_authorization_rule.metadata['url'], + template_url=self.get_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1775,67 +1954,65 @@ def get_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}"} # type: ignore - + get_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}" + } @distributed_trace def list_keys( - self, - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, authorization_rule_name: str, **kwargs: Any ) -> _models.AccessKeys: """Gets the primary and secondary connection strings for the namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + cls: ClsType[_models.AccessKeys] = kwargs.pop("cls", None) - request = build_list_keys_request( resource_group_name=resource_group_name, namespace_name=namespace_name, authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata['url'], + 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 + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1843,53 +2020,127 @@ def list_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + deserialized = self._deserialize("AccessKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/listKeys"} # type: ignore - + list_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/listKeys" + } - @distributed_trace + @overload def regenerate_keys( self, resource_group_name: str, namespace_name: str, authorization_rule_name: str, parameters: _models.RegenerateAccessKeyParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.AccessKeys: """Regenerates the primary or secondary connection strings for the namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate the authorization rule. + :param parameters: Parameters supplied to regenerate the authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.RegenerateAccessKeyParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AccessKeys: + """Regenerates the primary or secondary connection strings for the namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Required. + :type 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: AccessKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: Union[_models.RegenerateAccessKeyParameters, IO], + **kwargs: Any + ) -> _models.AccessKeys: + """Regenerates the primary or secondary connection strings for the namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.RegenerateAccessKeyParameters 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: AccessKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AccessKeys] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RegenerateAccessKeyParameters") request = build_regenerate_keys_request( resource_group_name=resource_group_name, @@ -1899,18 +2150,18 @@ def regenerate_keys( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_keys.metadata['url'], + content=_content, + template_url=self.regenerate_keys.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1918,62 +2169,108 @@ def regenerate_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + deserialized = self._deserialize("AccessKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/regenerateKeys"} # type: ignore + regenerate_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/regenerateKeys" + } + + @overload + def check_name_availability( + self, parameters: _models.CheckNameAvailability, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param parameters: Parameters to check availability of the given namespace name. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.CheckNameAvailability + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckNameAvailabilityResult or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + :param parameters: Parameters to check availability of the given namespace name. Required. + :type 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: CheckNameAvailabilityResult or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def check_name_availability( - self, - parameters: _models.CheckNameAvailability, - **kwargs: Any + self, parameters: Union[_models.CheckNameAvailability, IO], **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Check the give namespace name availability. - :param parameters: Parameters to check availability of the given namespace name. - :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.CheckNameAvailability + :param parameters: Parameters to check availability of the given namespace name. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.CheckNameAvailability 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: CheckNameAvailabilityResult, or the result of cls(response) + :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.CheckNameAvailabilityResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.CheckNameAvailabilityResult] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CheckNameAvailabilityResult] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'CheckNameAvailability') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "CheckNameAvailability") 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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1981,12 +2278,13 @@ def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) + deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/CheckNameAvailability"} # type: ignore - + check_name_availability.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/CheckNameAvailability" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/operations/_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/operations/_operations.py index b9ddcd40a230d..e3ec087b2c16b 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/operations/_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/operations/_operations.py @@ -6,11 +6,18 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,38 +27,38 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +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: + +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-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.ServiceBus/operations") # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class Operations: """ @@ -72,52 +79,56 @@ def __init__(self, *args, **kwargs): 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 ServiceBus 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.servicebus.v2021_11_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.servicebus.v2021_11_01.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', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_request( - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -125,16 +136,14 @@ 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) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -145,8 +154,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.ServiceBus/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.ServiceBus/operations"} diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/operations/_patch.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/operations/_patch.py index 0ad201a8c586e..f7dd32510333d 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/operations/_patch.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/operations/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/operations/_private_endpoint_connections_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/operations/_private_endpoint_connections_operations.py index 5c24300d79181..3fcae64edbe0f 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/operations/_private_endpoint_connections_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/operations/_private_endpoint_connections_operations.py @@ -6,11 +6,18 @@ # 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, Union, cast - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -22,134 +29,134 @@ 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') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +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, - namespace_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_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-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **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, namespace_name: str, private_endpoint_connection_name: str, - *, - json: Optional[_models.PrivateEndpointConnection] = None, - content: Any = None, + 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-11-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: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/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', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "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", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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') + _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, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( +def build_delete_request( resource_group_name: str, namespace_name: str, - subscription_id: 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', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( @@ -162,33 +169,35 @@ def build_get_request( _headers = case_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-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "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", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class PrivateEndpointConnectionsOperations: """ @@ -209,65 +218,67 @@ def __init__(self, *args, **kwargs): 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, - namespace_name: str, - **kwargs: Any - ) -> Iterable[_models.PrivateEndpointConnectionListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> Iterable["_models.PrivateEndpointConnection"]: """Gets the available PrivateEndpointConnections within a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateEndpointConnectionListResult or the result - of cls(response) + :return: An iterator like instance of either PrivateEndpointConnection or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.PrivateEndpointConnectionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_11_01.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', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnectionListResult] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -275,16 +286,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -295,71 +304,145 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections" + } - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, namespace_name: str, private_endpoint_connection_name: str, parameters: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.PrivateEndpointConnection: """Creates or updates PrivateEndpointConnections of service namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param private_endpoint_connection_name: The PrivateEndpointConnection name. + :param private_endpoint_connection_name: The PrivateEndpointConnection name. Required. :type private_endpoint_connection_name: str :param parameters: Parameters supplied to update Status of PrivateEndPoint Connection to - namespace resource. + namespace resource. Required. :type parameters: ~azure.mgmt.servicebus.v2021_11_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 + :return: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + private_endpoint_connection_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Creates or updates PrivateEndpointConnections of service namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param private_endpoint_connection_name: The PrivateEndpointConnection name. Required. + :type private_endpoint_connection_name: str + :param parameters: Parameters supplied to update Status of PrivateEndPoint Connection to + namespace resource. Required. + :type 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: PrivateEndpointConnection, or the result of cls(response) + :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + private_endpoint_connection_name: str, + parameters: Union[_models.PrivateEndpointConnection, IO], + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Creates or updates PrivateEndpointConnections of service namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param private_endpoint_connection_name: The PrivateEndpointConnection name. Required. + :type private_endpoint_connection_name: str + :param parameters: Parameters supplied to update Status of PrivateEndPoint Connection to + namespace resource. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_11_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 + :return: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'PrivateEndpointConnection') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PrivateEndpointConnection") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, namespace_name=namespace_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.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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -368,86 +451,82 @@ def create_or_update( 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 response.status_code == 202: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + return deserialized # type: ignore + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}" + } def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request_initial( + request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, - subscription_id=self._config.subscription_id, 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'], + 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 + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}" + } @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, namespace_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes an existing Private Endpoint Connection. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param private_endpoint_connection_name: The PrivateEndpointConnection name. + :param private_endpoint_connection_name: The PrivateEndpointConnection name. 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. @@ -459,108 +538,100 @@ def begin_delete( # pylint: disable=inconsistent-return-statements 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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: 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] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, namespace_name=namespace_name, private_endpoint_connection_name=private_endpoint_connection_name, api_version=api_version, - 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 = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}" + } @distributed_trace def get( - self, - resource_group_name: str, - namespace_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> _models.PrivateEndpointConnection: """Gets a description for the specified Private Endpoint Connection. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param private_endpoint_connection_name: The PrivateEndpointConnection name. + :param private_endpoint_connection_name: The PrivateEndpointConnection name. 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.servicebus.v2021_11_01.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_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'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -568,12 +639,13 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, 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.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/operations/_private_link_resources_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/operations/_private_link_resources_operations.py index 4b6c38cbe1ba9..2ca1bb2c3cec5 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/operations/_private_link_resources_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/operations/_private_link_resources_operations.py @@ -6,11 +6,17 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Optional, TypeVar -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest @@ -19,48 +25,52 @@ 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') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +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, - namespace_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_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-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateLinkResources") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateLinkResources", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class PrivateLinkResourcesOperations: """ @@ -81,54 +91,51 @@ def __init__(self, *args, **kwargs): 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, - namespace_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, **kwargs: Any ) -> _models.PrivateLinkResourcesListResult: """Gets lists of resources that supports Privatelinks. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateLinkResourcesListResult, or the result of cls(response) + :return: PrivateLinkResourcesListResult or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.PrivateLinkResourcesListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateLinkResourcesListResult] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + cls: ClsType[_models.PrivateLinkResourcesListResult] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -136,12 +143,13 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateLinkResourcesListResult', pipeline_response) + deserialized = self._deserialize("PrivateLinkResourcesListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateLinkResources"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateLinkResources" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/operations/_queues_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/operations/_queues_operations.py index 2396e8424900f..5c1384c79bf07 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/operations/_queues_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/operations/_queues_operations.py @@ -6,11 +6,18 @@ # 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 msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,50 +27,52 @@ 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') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_authorization_rules_request( - resource_group_name: str, - namespace_name: str, - queue_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, queue_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-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_authorization_rule_request( @@ -72,47 +81,43 @@ def build_create_or_update_authorization_rule_request( queue_name: str, authorization_rule_name: str, subscription_id: str, - *, - json: Optional[_models.SBAuthorizationRule] = None, - content: Any = 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', "2021-11-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: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', min_length=1), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, "str", min_length=1), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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') + _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, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_authorization_rule_request( @@ -126,34 +131,35 @@ def build_delete_authorization_rule_request( _headers = case_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-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', min_length=1), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, "str", min_length=1), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_authorization_rule_request( @@ -167,34 +173,35 @@ def build_get_authorization_rule_request( _headers = case_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-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', min_length=1), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, "str", min_length=1), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_keys_request( @@ -208,34 +215,35 @@ def build_list_keys_request( _headers = case_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-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/ListKeys") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/ListKeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', min_length=1), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, "str", min_length=1), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_regenerate_keys_request( @@ -244,47 +252,43 @@ def build_regenerate_keys_request( queue_name: str, authorization_rule_name: str, subscription_id: str, - *, - json: Optional[_models.RegenerateAccessKeyParameters] = None, - content: Any = 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', "2021-11-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: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/regenerateKeys") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/regenerateKeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', min_length=1), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, "str", min_length=1), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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') + _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, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_by_namespace_request( @@ -299,161 +303,141 @@ def build_list_by_namespace_request( _headers = case_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-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if skip is not None: - _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', maximum=1000, minimum=0) + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", maximum=1000, minimum=0) if top is not None: - _params['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", maximum=1000, minimum=1) # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( - resource_group_name: str, - namespace_name: str, - queue_name: str, - subscription_id: str, - *, - json: Optional[_models.SBQueue] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_name: str, queue_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-11-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: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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') + _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, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - namespace_name: str, - queue_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, queue_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-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - namespace_name: str, - queue_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, queue_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-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class QueuesOperations: """ @@ -474,70 +458,69 @@ def __init__(self, *args, **kwargs): 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_authorization_rules( - self, - resource_group_name: str, - namespace_name: str, - queue_name: str, - **kwargs: Any - ) -> Iterable[_models.SBAuthorizationRuleListResult]: + self, resource_group_name: str, namespace_name: str, queue_name: str, **kwargs: Any + ) -> Iterable["_models.SBAuthorizationRule"]: """Gets all authorization rules for a queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of - cls(response) + :return: An iterator like instance of either SBAuthorizationRule or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.SBAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.SBAuthorizationRule] + :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', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRuleListResult] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + cls: ClsType[_models.SBAuthorizationRuleListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_authorization_rules_request( resource_group_name=resource_group_name, namespace_name=namespace_name, queue_name=queue_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_authorization_rules.metadata['url'], + template_url=self.list_authorization_rules.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_authorization_rules_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - queue_name=queue_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -545,16 +528,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("SBAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -565,13 +546,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_authorization_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules"} # type: ignore + list_authorization_rules.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules" + } - @distributed_trace + @overload def create_or_update_authorization_rule( self, resource_group_name: str, @@ -579,38 +560,117 @@ def create_or_update_authorization_rule( queue_name: str, authorization_rule_name: str, parameters: _models.SBAuthorizationRule, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SBAuthorizationRule: """Creates an authorization rule for a queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: The shared access authorization rule. + :param parameters: The shared access authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.SBAuthorizationRule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBAuthorizationRule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates an authorization rule for a queue. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Required. + :type 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: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: Union[_models.SBAuthorizationRule, IO], + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates an authorization rule for a queue. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.SBAuthorizationRule 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: SBAuthorizationRule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SBAuthorizationRule] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'SBAuthorizationRule') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBAuthorizationRule") request = build_create_or_update_authorization_rule_request( resource_group_name=resource_group_name, @@ -621,18 +681,18 @@ def create_or_update_authorization_rule( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_authorization_rule.metadata['url'], + content=_content, + template_url=self.create_or_update_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -640,15 +700,16 @@ def create_or_update_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}"} # type: ignore - + create_or_update_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}" + } @distributed_trace def delete_authorization_rule( # pylint: disable=inconsistent-return-statements @@ -661,31 +722,33 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements ) -> None: """Deletes a queue authorization rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -693,18 +756,17 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_authorization_rule.metadata['url'], + template_url=self.delete_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -715,8 +777,9 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}"} # type: ignore - + delete_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}" + } @distributed_trace def get_authorization_rule( @@ -729,31 +792,33 @@ def get_authorization_rule( ) -> _models.SBAuthorizationRule: """Gets an authorization rule for a queue by rule name. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + cls: ClsType[_models.SBAuthorizationRule] = kwargs.pop("cls", None) - request = build_get_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -761,18 +826,17 @@ def get_authorization_rule( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_authorization_rule.metadata['url'], + template_url=self.get_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -780,15 +844,16 @@ def get_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}"} # type: ignore - + get_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}" + } @distributed_trace def list_keys( @@ -801,31 +866,33 @@ def list_keys( ) -> _models.AccessKeys: """Primary and secondary connection strings to the queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + cls: ClsType[_models.AccessKeys] = kwargs.pop("cls", None) - request = build_list_keys_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -833,18 +900,17 @@ def list_keys( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata['url'], + 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 + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -852,17 +918,18 @@ def list_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + deserialized = self._deserialize("AccessKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/ListKeys"} # type: ignore - + list_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/ListKeys" + } - @distributed_trace + @overload def regenerate_keys( self, resource_group_name: str, @@ -870,38 +937,117 @@ def regenerate_keys( queue_name: str, authorization_rule_name: str, parameters: _models.RegenerateAccessKeyParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.AccessKeys: """Regenerates the primary or secondary connection strings to the queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate the authorization rule. + :param parameters: Parameters supplied to regenerate the authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.RegenerateAccessKeyParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AccessKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AccessKeys: + """Regenerates the primary or secondary connection strings to the queue. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Required. + :type 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: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: Union[_models.RegenerateAccessKeyParameters, IO], + **kwargs: Any + ) -> _models.AccessKeys: + """Regenerates the primary or secondary connection strings to the queue. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.RegenerateAccessKeyParameters 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: AccessKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AccessKeys] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RegenerateAccessKeyParameters") request = build_regenerate_keys_request( resource_group_name=resource_group_name, @@ -912,18 +1058,18 @@ def regenerate_keys( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_keys.metadata['url'], + content=_content, + template_url=self.regenerate_keys.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -931,15 +1077,16 @@ def regenerate_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + deserialized = self._deserialize("AccessKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/regenerateKeys"} # type: ignore - + regenerate_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/regenerateKeys" + } @distributed_trace def list_by_namespace( @@ -949,12 +1096,12 @@ def list_by_namespace( skip: Optional[int] = None, top: Optional[int] = None, **kwargs: Any - ) -> Iterable[_models.SBQueueListResult]: + ) -> Iterable["_models.SBQueue"]: """Gets the queues within a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :param skip: Skip is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skip @@ -964,53 +1111,56 @@ def list_by_namespace( Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBQueueListResult or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.SBQueueListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either SBQueue or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.SBQueue] + :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', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBQueueListResult] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + cls: ClsType[_models.SBQueueListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_namespace_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, - api_version=api_version, skip=skip, top=top, - template_url=self.list_by_namespace.metadata['url'], + api_version=api_version, + template_url=self.list_by_namespace.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_by_namespace_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - skip=skip, - top=top, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -1018,16 +1168,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("SBQueueListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1038,49 +1186,122 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_namespace.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues"} # type: ignore + list_by_namespace.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues" + } - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, namespace_name: str, queue_name: str, parameters: _models.SBQueue, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SBQueue: """Creates or updates a Service Bus queue. This operation is idempotent. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param parameters: Parameters supplied to create or update a queue resource. + :param parameters: Parameters supplied to create or update a queue resource. Required. :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.SBQueue + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBQueue or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.SBQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBQueue: + """Creates or updates a Service Bus queue. This operation is idempotent. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param parameters: Parameters supplied to create or update a queue resource. Required. + :type 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: SBQueue, or the result of cls(response) + :return: SBQueue or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.SBQueue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + parameters: Union[_models.SBQueue, IO], + **kwargs: Any + ) -> _models.SBQueue: + """Creates or updates a Service Bus queue. This operation is idempotent. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param parameters: Parameters supplied to create or update a queue resource. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.SBQueue 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: SBQueue or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.SBQueue + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBQueue] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SBQueue] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'SBQueue') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBQueue") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -1090,18 +1311,18 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - 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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1109,67 +1330,65 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBQueue', pipeline_response) + deserialized = self._deserialize("SBQueue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}"} # type: ignore - + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}" + } @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - queue_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, queue_name: str, **kwargs: Any ) -> None: """Deletes a queue from the specified namespace in a resource group. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, queue_name=queue_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1180,60 +1399,56 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}"} # type: ignore - + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}" + } @distributed_trace - def get( - self, - resource_group_name: str, - namespace_name: str, - queue_name: str, - **kwargs: Any - ) -> _models.SBQueue: + def get(self, resource_group_name: str, namespace_name: str, queue_name: str, **kwargs: Any) -> _models.SBQueue: """Returns a description for the specified queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBQueue, or the result of cls(response) + :return: SBQueue or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.SBQueue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBQueue] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + cls: ClsType[_models.SBQueue] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, queue_name=queue_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1241,12 +1456,13 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBQueue', pipeline_response) + deserialized = self._deserialize("SBQueue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/operations/_rules_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/operations/_rules_operations.py index be66a582ba189..15f43cc4ce02e 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/operations/_rules_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/operations/_rules_operations.py @@ -6,11 +6,18 @@ # 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 msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,13 +27,20 @@ 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') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +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_subscriptions_request( resource_group_name: str, namespace_name: str, @@ -41,38 +55,37 @@ def build_list_by_subscriptions_request( _headers = case_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-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, "str", max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if skip is not None: - _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', maximum=1000, minimum=0) + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", maximum=1000, minimum=0) if top is not None: - _params['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", maximum=1000, minimum=1) # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( @@ -82,48 +95,42 @@ def build_create_or_update_request( subscription_name: str, rule_name: str, subscription_id: str, - *, - json: Optional[_models.Rule] = None, - content: Any = 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', "2021-11-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: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - "ruleName": _SERIALIZER.url("rule_name", rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, "str", max_length=50, min_length=1), + "ruleName": _SERIALIZER.url("rule_name", rule_name, "str", max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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') + _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, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( @@ -138,35 +145,34 @@ def build_delete_request( _headers = case_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-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - "ruleName": _SERIALIZER.url("rule_name", rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, "str", max_length=50, min_length=1), + "ruleName": _SERIALIZER.url("rule_name", rule_name, "str", max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( @@ -181,35 +187,35 @@ def build_get_request( _headers = case_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-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - "ruleName": _SERIALIZER.url("rule_name", rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, "str", max_length=50, min_length=1), + "ruleName": _SERIALIZER.url("rule_name", rule_name, "str", max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class RulesOperations: """ @@ -230,7 +236,6 @@ def __init__(self, *args, **kwargs): 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_subscriptions( self, @@ -241,16 +246,16 @@ def list_by_subscriptions( skip: Optional[int] = None, top: Optional[int] = None, **kwargs: Any - ) -> Iterable[_models.RuleListResult]: + ) -> Iterable["_models.Rule"]: """List all the rules within given topic-subscription. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str :param skip: Skip is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skip @@ -260,56 +265,58 @@ def list_by_subscriptions( Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RuleListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.RuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Rule or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.Rule] + :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', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.RuleListResult] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + cls: ClsType[_models.RuleListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscriptions_request( resource_group_name=resource_group_name, namespace_name=namespace_name, topic_name=topic_name, subscription_name=subscription_name, subscription_id=self._config.subscription_id, - api_version=api_version, skip=skip, top=top, - template_url=self.list_by_subscriptions.metadata['url'], + api_version=api_version, + template_url=self.list_by_subscriptions.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_by_subscriptions_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - topic_name=topic_name, - subscription_name=subscription_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - skip=skip, - top=top, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -317,16 +324,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("RuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -337,13 +342,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_subscriptions.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules"} # type: ignore + list_by_subscriptions.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules" + } - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, @@ -352,40 +357,125 @@ def create_or_update( subscription_name: str, rule_name: str, parameters: _models.Rule, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.Rule: """Creates a new rule and updates an existing rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str - :param rule_name: The rule name. + :param rule_name: The rule name. Required. :type rule_name: str - :param parameters: Parameters supplied to create a rule. + :param parameters: Parameters supplied to create a rule. Required. :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.Rule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Rule, or the result of cls(response) + :return: Rule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.Rule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Rule: + """Creates a new rule and updates an existing rule. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param rule_name: The rule name. Required. + :type rule_name: str + :param parameters: Parameters supplied to create a rule. Required. + :type 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: Rule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.Rule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + rule_name: str, + parameters: Union[_models.Rule, IO], + **kwargs: Any + ) -> _models.Rule: + """Creates a new rule and updates an existing rule. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param rule_name: The rule name. Required. + :type rule_name: str + :param parameters: Parameters supplied to create a rule. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.Rule 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: Rule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.Rule + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.Rule] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Rule] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'Rule') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Rule") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -397,18 +487,18 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - 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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -416,15 +506,16 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Rule', pipeline_response) + deserialized = self._deserialize("Rule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}"} # type: ignore - + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}" + } @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -438,33 +529,35 @@ def delete( # pylint: disable=inconsistent-return-statements ) -> None: """Deletes an existing rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str - :param rule_name: The rule name. + :param rule_name: The rule name. Required. :type rule_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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -473,18 +566,17 @@ def delete( # pylint: disable=inconsistent-return-statements rule_name=rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -495,8 +587,9 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}"} # type: ignore - + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}" + } @distributed_trace def get( @@ -510,33 +603,35 @@ def get( ) -> _models.Rule: """Retrieves the description for the specified rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str - :param rule_name: The rule name. + :param rule_name: The rule name. Required. :type rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Rule, or the result of cls(response) + :return: Rule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.Rule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Rule] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + cls: ClsType[_models.Rule] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -545,18 +640,17 @@ def get( rule_name=rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -564,12 +658,13 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Rule', pipeline_response) + deserialized = self._deserialize("Rule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/operations/_subscriptions_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/operations/_subscriptions_operations.py index 9ded268e4caa4..eadcc3ae4057f 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/operations/_subscriptions_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/operations/_subscriptions_operations.py @@ -6,11 +6,18 @@ # 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 msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,13 +27,20 @@ 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') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +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_topic_request( resource_group_name: str, namespace_name: str, @@ -40,37 +54,36 @@ def build_list_by_topic_request( _headers = case_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-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if skip is not None: - _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', maximum=1000, minimum=0) + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", maximum=1000, minimum=0) if top is not None: - _params['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", maximum=1000, minimum=1) # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( @@ -79,47 +92,41 @@ def build_create_or_update_request( topic_name: str, subscription_name: str, subscription_id: str, - *, - json: Optional[_models.SBSubscription] = None, - content: Any = 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', "2021-11-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: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, "str", max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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') + _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, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( @@ -133,34 +140,33 @@ def build_delete_request( _headers = case_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-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, "str", max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( @@ -174,34 +180,34 @@ def build_get_request( _headers = case_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-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, "str", max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class SubscriptionsOperations: """ @@ -222,7 +228,6 @@ def __init__(self, *args, **kwargs): 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_topic( self, @@ -232,14 +237,14 @@ def list_by_topic( skip: Optional[int] = None, top: Optional[int] = None, **kwargs: Any - ) -> Iterable[_models.SBSubscriptionListResult]: + ) -> Iterable["_models.SBSubscription"]: """List all the subscriptions under a specified topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str :param skip: Skip is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skip @@ -249,56 +254,57 @@ def list_by_topic( Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBSubscriptionListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.SBSubscriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either SBSubscription or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.SBSubscription] + :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', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBSubscriptionListResult] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + cls: ClsType[_models.SBSubscriptionListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_topic_request( resource_group_name=resource_group_name, namespace_name=namespace_name, topic_name=topic_name, subscription_id=self._config.subscription_id, - api_version=api_version, skip=skip, top=top, - template_url=self.list_by_topic.metadata['url'], + api_version=api_version, + template_url=self.list_by_topic.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_by_topic_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - topic_name=topic_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - skip=skip, - top=top, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -306,16 +312,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("SBSubscriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -326,13 +330,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_topic.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions"} # type: ignore + list_by_topic.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions" + } - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, @@ -340,38 +344,117 @@ def create_or_update( topic_name: str, subscription_name: str, parameters: _models.SBSubscription, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SBSubscription: """Creates a topic subscription. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str - :param parameters: Parameters supplied to create a subscription resource. + :param parameters: Parameters supplied to create a subscription resource. Required. :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.SBSubscription + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBSubscription or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.SBSubscription + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBSubscription: + """Creates a topic subscription. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param parameters: Parameters supplied to create a subscription resource. Required. + :type 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: SBSubscription or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.SBSubscription + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + parameters: Union[_models.SBSubscription, IO], + **kwargs: Any + ) -> _models.SBSubscription: + """Creates a topic subscription. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param parameters: Parameters supplied to create a subscription resource. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.SBSubscription 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: SBSubscription, or the result of cls(response) + :return: SBSubscription or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.SBSubscription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBSubscription] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SBSubscription] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'SBSubscription') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBSubscription") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -382,18 +465,18 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - 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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -401,52 +484,50 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBSubscription', pipeline_response) + deserialized = self._deserialize("SBSubscription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}"} # type: ignore - + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}" + } @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - subscription_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, topic_name: str, subscription_name: str, **kwargs: Any ) -> None: """Deletes a subscription from the specified topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -454,18 +535,17 @@ def delete( # pylint: disable=inconsistent-return-statements subscription_name=subscription_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -476,45 +556,43 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}"} # type: ignore - + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}" + } @distributed_trace def get( - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - subscription_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, topic_name: str, subscription_name: str, **kwargs: Any ) -> _models.SBSubscription: """Returns a subscription description for the specified topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBSubscription, or the result of cls(response) + :return: SBSubscription or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.SBSubscription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBSubscription] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + cls: ClsType[_models.SBSubscription] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -522,18 +600,17 @@ def get( subscription_name=subscription_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -541,12 +618,13 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBSubscription', pipeline_response) + deserialized = self._deserialize("SBSubscription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/operations/_topics_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/operations/_topics_operations.py index ba568af6a301d..c73ebb6668fcd 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/operations/_topics_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/operations/_topics_operations.py @@ -6,11 +6,18 @@ # 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 msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,50 +27,52 @@ 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') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_authorization_rules_request( - resource_group_name: str, - namespace_name: str, - topic_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, topic_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-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_authorization_rule_request( @@ -72,47 +81,43 @@ def build_create_or_update_authorization_rule_request( topic_name: str, authorization_rule_name: str, subscription_id: str, - *, - json: Optional[_models.SBAuthorizationRule] = None, - content: Any = 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', "2021-11-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: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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') + _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, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_get_authorization_rule_request( @@ -126,34 +131,35 @@ def build_get_authorization_rule_request( _headers = case_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-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_authorization_rule_request( @@ -167,34 +173,35 @@ def build_delete_authorization_rule_request( _headers = case_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-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_list_keys_request( @@ -208,34 +215,35 @@ def build_list_keys_request( _headers = case_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-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/ListKeys") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/ListKeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_regenerate_keys_request( @@ -244,47 +252,43 @@ def build_regenerate_keys_request( topic_name: str, authorization_rule_name: str, subscription_id: str, - *, - json: Optional[_models.RegenerateAccessKeyParameters] = None, - content: Any = 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', "2021-11-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: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/regenerateKeys") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/regenerateKeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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') + _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, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_by_namespace_request( @@ -299,161 +303,141 @@ def build_list_by_namespace_request( _headers = case_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-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if skip is not None: - _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', maximum=1000, minimum=0) + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", maximum=1000, minimum=0) if top is not None: - _params['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", maximum=1000, minimum=1) # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( - resource_group_name: str, - namespace_name: str, - topic_name: str, - subscription_id: str, - *, - json: Optional[_models.SBTopic] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_name: str, topic_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-11-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: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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') + _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, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - namespace_name: str, - topic_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, topic_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-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - namespace_name: str, - topic_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, topic_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-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class TopicsOperations: """ @@ -474,70 +458,69 @@ def __init__(self, *args, **kwargs): 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_authorization_rules( - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - **kwargs: Any - ) -> Iterable[_models.SBAuthorizationRuleListResult]: + self, resource_group_name: str, namespace_name: str, topic_name: str, **kwargs: Any + ) -> Iterable["_models.SBAuthorizationRule"]: """Gets authorization rules for a topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of - cls(response) + :return: An iterator like instance of either SBAuthorizationRule or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.SBAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.SBAuthorizationRule] + :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', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRuleListResult] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + cls: ClsType[_models.SBAuthorizationRuleListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_authorization_rules_request( resource_group_name=resource_group_name, namespace_name=namespace_name, topic_name=topic_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_authorization_rules.metadata['url'], + template_url=self.list_authorization_rules.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_authorization_rules_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - topic_name=topic_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -545,16 +528,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("SBAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -565,13 +546,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_authorization_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules"} # type: ignore + list_authorization_rules.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules" + } - @distributed_trace + @overload def create_or_update_authorization_rule( self, resource_group_name: str, @@ -579,38 +560,117 @@ def create_or_update_authorization_rule( topic_name: str, authorization_rule_name: str, parameters: _models.SBAuthorizationRule, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SBAuthorizationRule: """Creates an authorization rule for the specified topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: The shared access authorization rule. + :param parameters: The shared access authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.SBAuthorizationRule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBAuthorizationRule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates an authorization rule for the specified topic. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Required. + :type 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: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: Union[_models.SBAuthorizationRule, IO], + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates an authorization rule for the specified topic. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.SBAuthorizationRule 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: SBAuthorizationRule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SBAuthorizationRule] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'SBAuthorizationRule') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBAuthorizationRule") request = build_create_or_update_authorization_rule_request( resource_group_name=resource_group_name, @@ -621,18 +681,18 @@ def create_or_update_authorization_rule( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_authorization_rule.metadata['url'], + content=_content, + template_url=self.create_or_update_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -640,15 +700,16 @@ def create_or_update_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}"} # type: ignore - + create_or_update_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}" + } @distributed_trace def get_authorization_rule( @@ -661,31 +722,33 @@ def get_authorization_rule( ) -> _models.SBAuthorizationRule: """Returns the specified authorization rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + cls: ClsType[_models.SBAuthorizationRule] = kwargs.pop("cls", None) - request = build_get_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -693,18 +756,17 @@ def get_authorization_rule( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_authorization_rule.metadata['url'], + template_url=self.get_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -712,15 +774,16 @@ def get_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}"} # type: ignore - + get_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}" + } @distributed_trace def delete_authorization_rule( # pylint: disable=inconsistent-return-statements @@ -733,31 +796,33 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements ) -> None: """Deletes a topic authorization rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -765,18 +830,17 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_authorization_rule.metadata['url'], + template_url=self.delete_authorization_rule.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -787,8 +851,9 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}"} # type: ignore - + delete_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}" + } @distributed_trace def list_keys( @@ -801,31 +866,33 @@ def list_keys( ) -> _models.AccessKeys: """Gets the primary and secondary connection strings for the topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + cls: ClsType[_models.AccessKeys] = kwargs.pop("cls", None) - request = build_list_keys_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -833,18 +900,17 @@ def list_keys( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata['url'], + 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 + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -852,17 +918,18 @@ def list_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + deserialized = self._deserialize("AccessKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/ListKeys"} # type: ignore - + list_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/ListKeys" + } - @distributed_trace + @overload def regenerate_keys( self, resource_group_name: str, @@ -870,38 +937,117 @@ def regenerate_keys( topic_name: str, authorization_rule_name: str, parameters: _models.RegenerateAccessKeyParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.AccessKeys: """Regenerates primary or secondary connection strings for the topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate the authorization rule. + :param parameters: Parameters supplied to regenerate the authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.RegenerateAccessKeyParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AccessKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AccessKeys: + """Regenerates primary or secondary connection strings for the topic. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Required. + :type 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: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: Union[_models.RegenerateAccessKeyParameters, IO], + **kwargs: Any + ) -> _models.AccessKeys: + """Regenerates primary or secondary connection strings for the topic. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.RegenerateAccessKeyParameters 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: AccessKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AccessKeys] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RegenerateAccessKeyParameters") request = build_regenerate_keys_request( resource_group_name=resource_group_name, @@ -912,18 +1058,18 @@ def regenerate_keys( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_keys.metadata['url'], + content=_content, + template_url=self.regenerate_keys.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -931,15 +1077,16 @@ def regenerate_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + deserialized = self._deserialize("AccessKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/regenerateKeys"} # type: ignore - + regenerate_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/regenerateKeys" + } @distributed_trace def list_by_namespace( @@ -949,12 +1096,12 @@ def list_by_namespace( skip: Optional[int] = None, top: Optional[int] = None, **kwargs: Any - ) -> Iterable[_models.SBTopicListResult]: + ) -> Iterable["_models.SBTopic"]: """Gets all the topics in a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :param skip: Skip is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skip @@ -964,53 +1111,56 @@ def list_by_namespace( Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBTopicListResult or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.SBTopicListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either SBTopic or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.SBTopic] + :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', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBTopicListResult] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + cls: ClsType[_models.SBTopicListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_namespace_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, - api_version=api_version, skip=skip, top=top, - template_url=self.list_by_namespace.metadata['url'], + api_version=api_version, + template_url=self.list_by_namespace.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_by_namespace_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - skip=skip, - top=top, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -1018,16 +1168,14 @@ def extract_data(pipeline_response): deserialized = self._deserialize("SBTopicListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1038,49 +1186,122 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_namespace.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics"} # type: ignore + list_by_namespace.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics" + } - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, namespace_name: str, topic_name: str, parameters: _models.SBTopic, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SBTopic: """Creates a topic in the specified namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param parameters: Parameters supplied to create a topic resource. + :param parameters: Parameters supplied to create a topic resource. Required. :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.SBTopic + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBTopic or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.SBTopic + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBTopic: + """Creates a topic in the specified namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param parameters: Parameters supplied to create a topic resource. Required. + :type 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: SBTopic, or the result of cls(response) + :return: SBTopic or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.SBTopic - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + parameters: Union[_models.SBTopic, IO], + **kwargs: Any + ) -> _models.SBTopic: + """Creates a topic in the specified namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param parameters: Parameters supplied to create a topic resource. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.SBTopic 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: SBTopic or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.SBTopic + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBTopic] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SBTopic] = kwargs.pop("cls", None) - _json = self._serialize.body(parameters, 'SBTopic') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBTopic") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -1090,18 +1311,18 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - 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) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1109,67 +1330,65 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBTopic', pipeline_response) + deserialized = self._deserialize("SBTopic", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}"} # type: ignore - + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}" + } @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, topic_name: str, **kwargs: Any ) -> None: """Deletes a topic from the specified namespace and resource group. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_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: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, topic_name=topic_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1180,60 +1399,56 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}"} # type: ignore - + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}" + } @distributed_trace - def get( - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - **kwargs: Any - ) -> _models.SBTopic: + def get(self, resource_group_name: str, namespace_name: str, topic_name: str, **kwargs: Any) -> _models.SBTopic: """Returns a description for the specified topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBTopic, or the result of cls(response) + :return: SBTopic or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.SBTopic - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBTopic] + api_version: Literal["2021-11-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) + cls: ClsType[_models.SBTopic] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, topic_name=topic_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1241,12 +1456,13 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBTopic', pipeline_response) + deserialized = self._deserialize("SBTopic", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/operations/_disaster_recovery_configs_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/operations/_disaster_recovery_configs_operations.py deleted file mode 100644 index f67e9b774890f..0000000000000 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/operations/_disaster_recovery_configs_operations.py +++ /dev/null @@ -1,796 +0,0 @@ -# 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 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.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._disaster_recovery_configs_operations import build_break_pairing_request, build_check_name_availability_request, build_create_or_update_request, build_delete_request, build_fail_over_request, build_get_authorization_rule_request, build_get_request, build_list_authorization_rules_request, build_list_keys_request, build_list_request -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class DisasterRecoveryConfigsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.servicebus.v2022_01_01_preview.aio.ServiceBusManagementClient`'s - :attr:`disaster_recovery_configs` 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, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.ArmDisasterRecoveryListResult]: - """Gets all Alias(Disaster Recovery configurations). - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ArmDisasterRecoveryListResult or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2022_01_01_preview.models.ArmDisasterRecoveryListResult] - :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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ArmDisasterRecoveryListResult] - - 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( - resource_group_name=resource_group_name, - namespace_name=namespace_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 - - else: - - request = build_list_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_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("ArmDisasterRecoveryListResult", 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( # 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs"} # type: ignore - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - namespace_name: str, - alias: str, - parameters: _models.ArmDisasterRecovery, - **kwargs: Any - ) -> Optional[_models.ArmDisasterRecovery]: - """Creates or updates a new Alias(Disaster Recovery configuration). - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param alias: The Disaster Recovery configuration name. - :type alias: str - :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). - :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.ArmDisasterRecovery - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ArmDisasterRecovery, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.ArmDisasterRecovery or None - :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-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ArmDisasterRecovery]] - - _json = self._serialize.body(parameters, 'ArmDisasterRecovery') - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - alias=alias, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('ArmDisasterRecovery', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}"} # type: ignore - - - @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - alias: str, - **kwargs: Any - ) -> None: - """Deletes an Alias(Disaster Recovery configuration). - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param alias: The Disaster Recovery configuration name. - :type alias: 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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - - - request = build_delete_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - alias=alias, - subscription_id=self._config.subscription_id, - 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.ErrorResponse, 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.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}"} # type: ignore - - - @distributed_trace_async - async def get( - self, - resource_group_name: str, - namespace_name: str, - alias: str, - **kwargs: Any - ) -> _models.ArmDisasterRecovery: - """Retrieves Alias(Disaster Recovery configuration) for primary or secondary namespace. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param alias: The Disaster Recovery configuration name. - :type alias: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ArmDisasterRecovery, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.ArmDisasterRecovery - :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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ArmDisasterRecovery] - - - request = build_get_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - alias=alias, - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('ArmDisasterRecovery', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}"} # type: ignore - - - @distributed_trace_async - async def break_pairing( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - alias: str, - **kwargs: Any - ) -> None: - """This operation disables the Disaster Recovery and stops replicating changes from primary to - secondary namespaces. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param alias: The Disaster Recovery configuration name. - :type alias: 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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - - - request = build_break_pairing_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - alias=alias, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.break_pairing.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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - break_pairing.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/breakPairing"} # type: ignore - - - @distributed_trace_async - async def fail_over( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - alias: str, - parameters: Optional[_models.FailoverProperties] = None, - **kwargs: Any - ) -> None: - """Invokes GEO DR failover and reconfigure the alias to point to the secondary namespace. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param alias: The Disaster Recovery configuration name. - :type alias: str - :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). - Default value is None. - :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.FailoverProperties - :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 = case_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-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[None] - - if parameters is not None: - _json = self._serialize.body(parameters, 'FailoverProperties') - else: - _json = None - - request = build_fail_over_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - alias=alias, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - template_url=self.fail_over.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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - fail_over.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/failover"} # type: ignore - - - @distributed_trace - def list_authorization_rules( - self, - resource_group_name: str, - namespace_name: str, - alias: str, - **kwargs: Any - ) -> AsyncIterable[_models.SBAuthorizationRuleListResult]: - """Gets the authorization rules for a namespace. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param alias: The Disaster Recovery configuration name. - :type alias: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2022_01_01_preview.models.SBAuthorizationRuleListResult] - :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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRuleListResult] - - 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_authorization_rules_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - alias=alias, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_authorization_rules.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - else: - - request = build_list_authorization_rules_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - alias=alias, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_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("SBAuthorizationRuleListResult", 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( # 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - - return AsyncItemPaged( - get_next, extract_data - ) - list_authorization_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules"} # type: ignore - - @distributed_trace_async - async def get_authorization_rule( - self, - resource_group_name: str, - namespace_name: str, - alias: str, - authorization_rule_name: str, - **kwargs: Any - ) -> _models.SBAuthorizationRule: - """Gets an authorization rule for a namespace by rule name. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param alias: The Disaster Recovery configuration name. - :type alias: str - :param authorization_rule_name: The authorization rule name. - :type authorization_rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBAuthorizationRule - :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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] - - - request = build_get_authorization_rule_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - alias=alias, - authorization_rule_name=authorization_rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get_authorization_rule.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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules/{authorizationRuleName}"} # type: ignore - - - @distributed_trace_async - async def list_keys( - self, - resource_group_name: str, - namespace_name: str, - alias: str, - authorization_rule_name: str, - **kwargs: Any - ) -> _models.AccessKeys: - """Gets the primary and secondary connection strings for the namespace. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param alias: The Disaster Recovery configuration name. - :type alias: str - :param authorization_rule_name: The authorization rule name. - :type authorization_rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.AccessKeys - :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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] - - - request = build_list_keys_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - alias=alias, - authorization_rule_name=authorization_rule_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 - - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('AccessKeys', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules/{authorizationRuleName}/listKeys"} # type: ignore - - - @distributed_trace_async - async def check_name_availability( - self, - resource_group_name: str, - namespace_name: str, - parameters: _models.CheckNameAvailability, - **kwargs: Any - ) -> _models.CheckNameAvailabilityResult: - """Check the give namespace name availability. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param parameters: Parameters to check availability of the given namespace name. - :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.CheckNameAvailability - :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckNameAvailabilityResult, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.CheckNameAvailabilityResult - :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-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.CheckNameAvailabilityResult] - - _json = self._serialize.body(parameters, 'CheckNameAvailability') - - request = build_check_name_availability_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/CheckNameAvailability"} # type: ignore - diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/operations/_migration_configs_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/operations/_migration_configs_operations.py deleted file mode 100644 index 0cb763195c646..0000000000000 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/operations/_migration_configs_operations.py +++ /dev/null @@ -1,553 +0,0 @@ -# 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, Union, cast - -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._migration_configs_operations import build_complete_migration_request, build_create_and_start_migration_request_initial, build_delete_request, build_get_request, build_list_request, build_revert_request -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class MigrationConfigsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.servicebus.v2022_01_01_preview.aio.ServiceBusManagementClient`'s - :attr:`migration_configs` 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, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.MigrationConfigListResult]: - """Gets all migrationConfigurations. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MigrationConfigListResult or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2022_01_01_preview.models.MigrationConfigListResult] - :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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MigrationConfigListResult] - - 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( - resource_group_name=resource_group_name, - namespace_name=namespace_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 - - else: - - request = build_list_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_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("MigrationConfigListResult", 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( # 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations"} # type: ignore - - async def _create_and_start_migration_initial( - self, - resource_group_name: str, - namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], - parameters: _models.MigrationConfigProperties, - **kwargs: Any - ) -> Optional[_models.MigrationConfigProperties]: - 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-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.MigrationConfigProperties]] - - _json = self._serialize.body(parameters, 'MigrationConfigProperties') - - request = build_create_and_start_migration_request_initial( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - config_name=config_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - template_url=self._create_and_start_migration_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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('MigrationConfigProperties', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _create_and_start_migration_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}"} # type: ignore - - - @distributed_trace_async - async def begin_create_and_start_migration( - self, - resource_group_name: str, - namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], - parameters: _models.MigrationConfigProperties, - **kwargs: Any - ) -> AsyncLROPoller[_models.MigrationConfigProperties]: - """Creates Migration configuration and starts migration of entities from Standard to Premium - namespace. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". - :type config_name: str or - ~azure.mgmt.servicebus.v2022_01_01_preview.models.MigrationConfigurationName - :param parameters: Parameters required to create Migration Configuration. - :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.MigrationConfigProperties - :keyword callable cls: A custom type 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 MigrationConfigProperties or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.servicebus.v2022_01_01_preview.models.MigrationConfigProperties] - :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-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.MigrationConfigProperties] - 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_and_start_migration_initial( # type: ignore - resource_group_name=resource_group_name, - namespace_name=namespace_name, - config_name=config_name, - parameters=parameters, - 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('MigrationConfigProperties', 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_and_start_migration.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}"} # type: ignore - - @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], - **kwargs: Any - ) -> None: - """Deletes a MigrationConfiguration. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". - :type config_name: str or - ~azure.mgmt.servicebus.v2022_01_01_preview.models.MigrationConfigurationName - :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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - - - request = build_delete_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - config_name=config_name, - subscription_id=self._config.subscription_id, - 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.ErrorResponse, 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.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}"} # type: ignore - - - @distributed_trace_async - async def get( - self, - resource_group_name: str, - namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], - **kwargs: Any - ) -> _models.MigrationConfigProperties: - """Retrieves Migration Config. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". - :type config_name: str or - ~azure.mgmt.servicebus.v2022_01_01_preview.models.MigrationConfigurationName - :keyword callable cls: A custom type or function that will be passed the direct response - :return: MigrationConfigProperties, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.MigrationConfigProperties - :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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MigrationConfigProperties] - - - request = build_get_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - config_name=config_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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('MigrationConfigProperties', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}"} # type: ignore - - - @distributed_trace_async - async def complete_migration( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], - **kwargs: Any - ) -> None: - """This operation Completes Migration of entities by pointing the connection strings to Premium - namespace and any entities created after the operation will be under Premium Namespace. - CompleteMigration operation will fail when entity migration is in-progress. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". - :type config_name: str or - ~azure.mgmt.servicebus.v2022_01_01_preview.models.MigrationConfigurationName - :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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - - - request = build_complete_migration_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - config_name=config_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.complete_migration.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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - complete_migration.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/upgrade"} # type: ignore - - - @distributed_trace_async - async def revert( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], - **kwargs: Any - ) -> None: - """This operation reverts Migration. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". - :type config_name: str or - ~azure.mgmt.servicebus.v2022_01_01_preview.models.MigrationConfigurationName - :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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - - - request = build_revert_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - config_name=config_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.revert.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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - revert.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/revert"} # type: ignore - diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/operations/_namespaces_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/operations/_namespaces_operations.py deleted file mode 100644 index a2767c6538bc7..0000000000000 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/operations/_namespaces_operations.py +++ /dev/null @@ -1,1352 +0,0 @@ -# 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, Union, cast - -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._namespaces_operations import build_check_name_availability_request, build_create_or_update_authorization_rule_request, build_create_or_update_network_rule_set_request, build_create_or_update_request_initial, build_delete_authorization_rule_request, build_delete_request_initial, build_get_authorization_rule_request, build_get_network_rule_set_request, build_get_request, build_list_authorization_rules_request, build_list_by_resource_group_request, build_list_keys_request, build_list_network_rule_sets_request, build_list_request, build_regenerate_keys_request, build_update_request -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class NamespacesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.servicebus.v2022_01_01_preview.aio.ServiceBusManagementClient`'s - :attr:`namespaces` 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.SBNamespaceListResult]: - """Gets all the available namespaces within the subscription, irrespective of the resource groups. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBNamespaceListResult or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2022_01_01_preview.models.SBNamespaceListResult] - :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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBNamespaceListResult] - - 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( - 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 - - else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_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("SBNamespaceListResult", 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( # 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/namespaces"} # type: ignore - - @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.SBNamespaceListResult]: - """Gets the available namespaces within a resource group. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :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 SBNamespaceListResult or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2022_01_01_preview.models.SBNamespaceListResult] - :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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBNamespaceListResult] - - 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: - - 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=next_link, - headers=_headers, - params=_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("SBNamespaceListResult", 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( # 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.ErrorResponse, 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.ServiceBus/namespaces"} # type: ignore - - async def _create_or_update_initial( - self, - resource_group_name: str, - namespace_name: str, - parameters: _models.SBNamespace, - **kwargs: Any - ) -> Optional[_models.SBNamespace]: - 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-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.SBNamespace]] - - _json = self._serialize.body(parameters, 'SBNamespace') - - request = build_create_or_update_request_initial( - resource_group_name=resource_group_name, - namespace_name=namespace_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'], - 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, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('SBNamespace', pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize('SBNamespace', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore - - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - namespace_name: str, - parameters: _models.SBNamespace, - **kwargs: Any - ) -> AsyncLROPoller[_models.SBNamespace]: - """Creates or updates a service namespace. Once created, this namespace's resource manifest is - immutable. This operation is idempotent. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param parameters: Parameters supplied to create a namespace resource. - :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBNamespace - :keyword callable cls: A custom type 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 SBNamespace or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.servicebus.v2022_01_01_preview.models.SBNamespace] - :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-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBNamespace] - 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, - namespace_name=namespace_name, - parameters=parameters, - 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('SBNamespace', 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.ServiceBus/namespaces/{namespaceName}"} # type: ignore - - async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) 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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - - - request = build_delete_request_initial( - resource_group_name=resource_group_name, - namespace_name=namespace_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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore - - - @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes an existing namespace. This operation also removes all associated resources under the - namespace. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_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 None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :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-01-01-preview")) # type: 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._delete_initial( # type: ignore - resource_group_name=resource_group_name, - namespace_name=namespace_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): - 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_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore - - @distributed_trace_async - async def get( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> _models.SBNamespace: - """Gets a description for the specified namespace. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBNamespace, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBNamespace - :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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBNamespace] - - - request = build_get_request( - resource_group_name=resource_group_name, - namespace_name=namespace_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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('SBNamespace', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore - - - @distributed_trace_async - async def update( - self, - resource_group_name: str, - namespace_name: str, - parameters: _models.SBNamespaceUpdateParameters, - **kwargs: Any - ) -> Optional[_models.SBNamespace]: - """Updates a service namespace. Once created, this namespace's resource manifest is immutable. - This operation is idempotent. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param parameters: Parameters supplied to update a namespace resource. - :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBNamespaceUpdateParameters - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBNamespace, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBNamespace or None - :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-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.SBNamespace]] - - _json = self._serialize.body(parameters, 'SBNamespaceUpdateParameters') - - request = build_update_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - template_url=self.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, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('SBNamespace', pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize('SBNamespace', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore - - - @distributed_trace_async - async def create_or_update_network_rule_set( - self, - resource_group_name: str, - namespace_name: str, - parameters: _models.NetworkRuleSet, - **kwargs: Any - ) -> _models.NetworkRuleSet: - """Create or update NetworkRuleSet for a Namespace. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param parameters: The Namespace IpFilterRule. - :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.NetworkRuleSet - :keyword callable cls: A custom type or function that will be passed the direct response - :return: NetworkRuleSet, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.NetworkRuleSet - :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-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.NetworkRuleSet] - - _json = self._serialize.body(parameters, 'NetworkRuleSet') - - request = build_create_or_update_network_rule_set_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - template_url=self.create_or_update_network_rule_set.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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('NetworkRuleSet', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create_or_update_network_rule_set.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default"} # type: ignore - - - @distributed_trace_async - async def get_network_rule_set( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> _models.NetworkRuleSet: - """Gets NetworkRuleSet for a Namespace. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: NetworkRuleSet, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.NetworkRuleSet - :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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.NetworkRuleSet] - - - request = build_get_network_rule_set_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get_network_rule_set.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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('NetworkRuleSet', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_network_rule_set.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default"} # type: ignore - - - @distributed_trace - def list_network_rule_sets( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.NetworkRuleSetListResult]: - """Gets list of NetworkRuleSet for a Namespace. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either NetworkRuleSetListResult or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2022_01_01_preview.models.NetworkRuleSetListResult] - :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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.NetworkRuleSetListResult] - - 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_network_rule_sets_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_network_rule_sets.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - else: - - request = build_list_network_rule_sets_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_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("NetworkRuleSetListResult", 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( # 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - - return AsyncItemPaged( - get_next, extract_data - ) - list_network_rule_sets.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets"} # type: ignore - - @distributed_trace - def list_authorization_rules( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.SBAuthorizationRuleListResult]: - """Gets the authorization rules for a namespace. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2022_01_01_preview.models.SBAuthorizationRuleListResult] - :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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRuleListResult] - - 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_authorization_rules_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_authorization_rules.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - else: - - request = build_list_authorization_rules_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_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("SBAuthorizationRuleListResult", 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( # 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - - return AsyncItemPaged( - get_next, extract_data - ) - list_authorization_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules"} # type: ignore - - @distributed_trace_async - async def create_or_update_authorization_rule( - self, - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - parameters: _models.SBAuthorizationRule, - **kwargs: Any - ) -> _models.SBAuthorizationRule: - """Creates or updates an authorization rule for a namespace. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param authorization_rule_name: The authorization rule name. - :type authorization_rule_name: str - :param parameters: The shared access authorization rule. - :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBAuthorizationRule - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBAuthorizationRule - :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-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] - - _json = self._serialize.body(parameters, 'SBAuthorizationRule') - - request = build_create_or_update_authorization_rule_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - authorization_rule_name=authorization_rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - template_url=self.create_or_update_authorization_rule.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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create_or_update_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}"} # type: ignore - - - @distributed_trace_async - async def delete_authorization_rule( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - **kwargs: Any - ) -> None: - """Deletes a namespace authorization rule. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param authorization_rule_name: The authorization rule name. - :type authorization_rule_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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - - - request = build_delete_authorization_rule_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - authorization_rule_name=authorization_rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.delete_authorization_rule.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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}"} # type: ignore - - - @distributed_trace_async - async def get_authorization_rule( - self, - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - **kwargs: Any - ) -> _models.SBAuthorizationRule: - """Gets an authorization rule for a namespace by rule name. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param authorization_rule_name: The authorization rule name. - :type authorization_rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBAuthorizationRule - :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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] - - - request = build_get_authorization_rule_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - authorization_rule_name=authorization_rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get_authorization_rule.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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}"} # type: ignore - - - @distributed_trace_async - async def list_keys( - self, - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - **kwargs: Any - ) -> _models.AccessKeys: - """Gets the primary and secondary connection strings for the namespace. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param authorization_rule_name: The authorization rule name. - :type authorization_rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.AccessKeys - :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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] - - - request = build_list_keys_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - authorization_rule_name=authorization_rule_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 - - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('AccessKeys', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/listKeys"} # type: ignore - - - @distributed_trace_async - async def regenerate_keys( - self, - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - parameters: _models.RegenerateAccessKeyParameters, - **kwargs: Any - ) -> _models.AccessKeys: - """Regenerates the primary or secondary connection strings for the namespace. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param authorization_rule_name: The authorization rule name. - :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate the authorization rule. - :type parameters: - ~azure.mgmt.servicebus.v2022_01_01_preview.models.RegenerateAccessKeyParameters - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.AccessKeys - :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-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] - - _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') - - request = build_regenerate_keys_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - authorization_rule_name=authorization_rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - template_url=self.regenerate_keys.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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('AccessKeys', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - regenerate_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/regenerateKeys"} # type: ignore - - - @distributed_trace_async - async def check_name_availability( - self, - parameters: _models.CheckNameAvailability, - **kwargs: Any - ) -> _models.CheckNameAvailabilityResult: - """Check the give namespace name availability. - - :param parameters: Parameters to check availability of the given namespace name. - :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.CheckNameAvailability - :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckNameAvailabilityResult, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.CheckNameAvailabilityResult - :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-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.CheckNameAvailabilityResult] - - _json = self._serialize.body(parameters, 'CheckNameAvailability') - - 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'], - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/CheckNameAvailability"} # type: ignore - diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/operations/_private_endpoint_connections_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/operations/_private_endpoint_connections_operations.py deleted file mode 100644 index 17fc571750fa3..0000000000000 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/operations/_private_endpoint_connections_operations.py +++ /dev/null @@ -1,415 +0,0 @@ -# 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, Union, cast - -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._private_endpoint_connections_operations import build_create_or_update_request, build_delete_request_initial, build_get_request, build_list_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.servicebus.v2022_01_01_preview.aio.ServiceBusManagementClient`'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 - def list( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.PrivateEndpointConnectionListResult]: - """Gets the available PrivateEndpointConnections within a namespace. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateEndpointConnectionListResult or the result - of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2022_01_01_preview.models.PrivateEndpointConnectionListResult] - :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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnectionListResult] - - 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( - resource_group_name=resource_group_name, - namespace_name=namespace_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 - - else: - - request = build_list_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_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("PrivateEndpointConnectionListResult", 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( # 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections"} # type: ignore - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - namespace_name: str, - private_endpoint_connection_name: str, - parameters: _models.PrivateEndpointConnection, - **kwargs: Any - ) -> _models.PrivateEndpointConnection: - """Creates or updates PrivateEndpointConnections of service namespace. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param private_endpoint_connection_name: The PrivateEndpointConnection name. - :type private_endpoint_connection_name: str - :param parameters: Parameters supplied to update Status of PrivateEndPoint Connection to - namespace resource. - :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.PrivateEndpointConnection - :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.servicebus.v2022_01_01_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 = case_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-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] - - _json = self._serialize.body(parameters, 'PrivateEndpointConnection') - - request = build_create_or_update_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - namespace_name=namespace_name, - private_endpoint_connection_name=private_endpoint_connection_name, - api_version=api_version, - content_type=content_type, - json=_json, - 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, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - - - async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - private_endpoint_connection_name: str, - **kwargs: Any - ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) 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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - - - request = build_delete_request_initial( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - private_endpoint_connection_name=private_endpoint_connection_name, - 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - - - @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - private_endpoint_connection_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes an existing Private Endpoint Connection. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param private_endpoint_connection_name: The PrivateEndpointConnection name. - :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 None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :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-01-01-preview")) # type: 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._delete_initial( # type: ignore - resource_group_name=resource_group_name, - namespace_name=namespace_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): - 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_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - - @distributed_trace_async - async def get( - self, - resource_group_name: str, - namespace_name: str, - private_endpoint_connection_name: str, - **kwargs: Any - ) -> _models.PrivateEndpointConnection: - """Gets a description for the specified Private Endpoint Connection. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param private_endpoint_connection_name: The PrivateEndpointConnection name. - :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.servicebus.v2022_01_01_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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] - - - request = build_get_request( - resource_group_name=resource_group_name, - namespace_name=namespace_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.ErrorResponse, 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.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/operations/_queues_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/operations/_queues_operations.py deleted file mode 100644 index 7f7e1f04ab7a2..0000000000000 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/operations/_queues_operations.py +++ /dev/null @@ -1,822 +0,0 @@ -# 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 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.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._queues_operations import build_create_or_update_authorization_rule_request, build_create_or_update_request, build_delete_authorization_rule_request, build_delete_request, build_get_authorization_rule_request, build_get_request, build_list_authorization_rules_request, build_list_by_namespace_request, build_list_keys_request, build_regenerate_keys_request -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class QueuesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.servicebus.v2022_01_01_preview.aio.ServiceBusManagementClient`'s - :attr:`queues` 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_authorization_rules( - self, - resource_group_name: str, - namespace_name: str, - queue_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.SBAuthorizationRuleListResult]: - """Gets all authorization rules for a queue. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param queue_name: The queue name. - :type queue_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2022_01_01_preview.models.SBAuthorizationRuleListResult] - :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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRuleListResult] - - 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_authorization_rules_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - queue_name=queue_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_authorization_rules.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - else: - - request = build_list_authorization_rules_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - queue_name=queue_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_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("SBAuthorizationRuleListResult", 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( # 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - - return AsyncItemPaged( - get_next, extract_data - ) - list_authorization_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules"} # type: ignore - - @distributed_trace_async - async def create_or_update_authorization_rule( - self, - resource_group_name: str, - namespace_name: str, - queue_name: str, - authorization_rule_name: str, - parameters: _models.SBAuthorizationRule, - **kwargs: Any - ) -> _models.SBAuthorizationRule: - """Creates an authorization rule for a queue. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param queue_name: The queue name. - :type queue_name: str - :param authorization_rule_name: The authorization rule name. - :type authorization_rule_name: str - :param parameters: The shared access authorization rule. - :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBAuthorizationRule - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBAuthorizationRule - :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-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] - - _json = self._serialize.body(parameters, 'SBAuthorizationRule') - - request = build_create_or_update_authorization_rule_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - queue_name=queue_name, - authorization_rule_name=authorization_rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - template_url=self.create_or_update_authorization_rule.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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create_or_update_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}"} # type: ignore - - - @distributed_trace_async - async def delete_authorization_rule( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - queue_name: str, - authorization_rule_name: str, - **kwargs: Any - ) -> None: - """Deletes a queue authorization rule. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param queue_name: The queue name. - :type queue_name: str - :param authorization_rule_name: The authorization rule name. - :type authorization_rule_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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - - - request = build_delete_authorization_rule_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - queue_name=queue_name, - authorization_rule_name=authorization_rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.delete_authorization_rule.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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}"} # type: ignore - - - @distributed_trace_async - async def get_authorization_rule( - self, - resource_group_name: str, - namespace_name: str, - queue_name: str, - authorization_rule_name: str, - **kwargs: Any - ) -> _models.SBAuthorizationRule: - """Gets an authorization rule for a queue by rule name. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param queue_name: The queue name. - :type queue_name: str - :param authorization_rule_name: The authorization rule name. - :type authorization_rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBAuthorizationRule - :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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] - - - request = build_get_authorization_rule_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - queue_name=queue_name, - authorization_rule_name=authorization_rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get_authorization_rule.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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}"} # type: ignore - - - @distributed_trace_async - async def list_keys( - self, - resource_group_name: str, - namespace_name: str, - queue_name: str, - authorization_rule_name: str, - **kwargs: Any - ) -> _models.AccessKeys: - """Primary and secondary connection strings to the queue. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param queue_name: The queue name. - :type queue_name: str - :param authorization_rule_name: The authorization rule name. - :type authorization_rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.AccessKeys - :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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] - - - request = build_list_keys_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - queue_name=queue_name, - authorization_rule_name=authorization_rule_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 - - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('AccessKeys', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/ListKeys"} # type: ignore - - - @distributed_trace_async - async def regenerate_keys( - self, - resource_group_name: str, - namespace_name: str, - queue_name: str, - authorization_rule_name: str, - parameters: _models.RegenerateAccessKeyParameters, - **kwargs: Any - ) -> _models.AccessKeys: - """Regenerates the primary or secondary connection strings to the queue. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param queue_name: The queue name. - :type queue_name: str - :param authorization_rule_name: The authorization rule name. - :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate the authorization rule. - :type parameters: - ~azure.mgmt.servicebus.v2022_01_01_preview.models.RegenerateAccessKeyParameters - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.AccessKeys - :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-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] - - _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') - - request = build_regenerate_keys_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - queue_name=queue_name, - authorization_rule_name=authorization_rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - template_url=self.regenerate_keys.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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('AccessKeys', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - regenerate_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/regenerateKeys"} # type: ignore - - - @distributed_trace - def list_by_namespace( - self, - resource_group_name: str, - namespace_name: str, - skip: Optional[int] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable[_models.SBQueueListResult]: - """Gets the queues within a namespace. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param skip: Skip is only used if a previous operation returned a partial result. If a previous - response contains a nextLink element, the value of the nextLink element will include a skip - parameter that specifies a starting point to use for subsequent calls. Default value is None. - :type skip: int - :param top: May be used to limit the number of results to the most recent N usageDetails. - Default value is None. - :type top: int - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBQueueListResult or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2022_01_01_preview.models.SBQueueListResult] - :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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBQueueListResult] - - 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_namespace_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - skip=skip, - top=top, - template_url=self.list_by_namespace.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - else: - - request = build_list_by_namespace_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - skip=skip, - top=top, - template_url=next_link, - headers=_headers, - params=_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("SBQueueListResult", 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( # 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - - return AsyncItemPaged( - get_next, extract_data - ) - list_by_namespace.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues"} # type: ignore - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - namespace_name: str, - queue_name: str, - parameters: _models.SBQueue, - **kwargs: Any - ) -> _models.SBQueue: - """Creates or updates a Service Bus queue. This operation is idempotent. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param queue_name: The queue name. - :type queue_name: str - :param parameters: Parameters supplied to create or update a queue resource. - :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBQueue - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBQueue, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBQueue - :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-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBQueue] - - _json = self._serialize.body(parameters, 'SBQueue') - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - queue_name=queue_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - 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]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('SBQueue', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}"} # type: ignore - - - @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - queue_name: str, - **kwargs: Any - ) -> None: - """Deletes a queue from the specified namespace in a resource group. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param queue_name: The queue name. - :type queue_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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - - - request = build_delete_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - queue_name=queue_name, - subscription_id=self._config.subscription_id, - 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.ErrorResponse, 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.ServiceBus/namespaces/{namespaceName}/queues/{queueName}"} # type: ignore - - - @distributed_trace_async - async def get( - self, - resource_group_name: str, - namespace_name: str, - queue_name: str, - **kwargs: Any - ) -> _models.SBQueue: - """Returns a description for the specified queue. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param queue_name: The queue name. - :type queue_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBQueue, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBQueue - :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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBQueue] - - - request = build_get_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - queue_name=queue_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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('SBQueue', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}"} # type: ignore - diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/operations/_rules_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/operations/_rules_operations.py deleted file mode 100644 index 3fe195decf17e..0000000000000 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/operations/_rules_operations.py +++ /dev/null @@ -1,389 +0,0 @@ -# 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 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.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._rules_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_by_subscriptions_request -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class RulesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.servicebus.v2022_01_01_preview.aio.ServiceBusManagementClient`'s - :attr:`rules` 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_by_subscriptions( - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - subscription_name: str, - skip: Optional[int] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable[_models.RuleListResult]: - """List all the rules within given topic-subscription. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param topic_name: The topic name. - :type topic_name: str - :param subscription_name: The subscription name. - :type subscription_name: str - :param skip: Skip is only used if a previous operation returned a partial result. If a previous - response contains a nextLink element, the value of the nextLink element will include a skip - parameter that specifies a starting point to use for subsequent calls. Default value is None. - :type skip: int - :param top: May be used to limit the number of results to the most recent N usageDetails. - Default value is None. - :type top: int - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RuleListResult or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2022_01_01_preview.models.RuleListResult] - :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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.RuleListResult] - - 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_subscriptions_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - topic_name=topic_name, - subscription_name=subscription_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - skip=skip, - top=top, - template_url=self.list_by_subscriptions.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - else: - - request = build_list_by_subscriptions_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - topic_name=topic_name, - subscription_name=subscription_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - skip=skip, - top=top, - template_url=next_link, - headers=_headers, - params=_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("RuleListResult", 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( # 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - - return AsyncItemPaged( - get_next, extract_data - ) - list_by_subscriptions.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules"} # type: ignore - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - subscription_name: str, - rule_name: str, - parameters: _models.Rule, - **kwargs: Any - ) -> _models.Rule: - """Creates a new rule and updates an existing rule. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param topic_name: The topic name. - :type topic_name: str - :param subscription_name: The subscription name. - :type subscription_name: str - :param rule_name: The rule name. - :type rule_name: str - :param parameters: Parameters supplied to create a rule. - :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.Rule - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Rule, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.Rule - :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-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.Rule] - - _json = self._serialize.body(parameters, 'Rule') - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - topic_name=topic_name, - subscription_name=subscription_name, - rule_name=rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - 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]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('Rule', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}"} # type: ignore - - - @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - subscription_name: str, - rule_name: str, - **kwargs: Any - ) -> None: - """Deletes an existing rule. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param topic_name: The topic name. - :type topic_name: str - :param subscription_name: The subscription name. - :type subscription_name: str - :param rule_name: The rule name. - :type rule_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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - - - request = build_delete_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - topic_name=topic_name, - subscription_name=subscription_name, - rule_name=rule_name, - subscription_id=self._config.subscription_id, - 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.ErrorResponse, 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.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}"} # type: ignore - - - @distributed_trace_async - async def get( - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - subscription_name: str, - rule_name: str, - **kwargs: Any - ) -> _models.Rule: - """Retrieves the description for the specified rule. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param topic_name: The topic name. - :type topic_name: str - :param subscription_name: The subscription name. - :type subscription_name: str - :param rule_name: The rule name. - :type rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Rule, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.Rule - :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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Rule] - - - request = build_get_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - topic_name=topic_name, - subscription_name=subscription_name, - rule_name=rule_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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('Rule', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}"} # type: ignore - diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/operations/_subscriptions_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/operations/_subscriptions_operations.py deleted file mode 100644 index b4a603ce4f1d0..0000000000000 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/operations/_subscriptions_operations.py +++ /dev/null @@ -1,373 +0,0 @@ -# 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 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.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._subscriptions_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_by_topic_request -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class SubscriptionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.servicebus.v2022_01_01_preview.aio.ServiceBusManagementClient`'s - :attr:`subscriptions` 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_by_topic( - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - skip: Optional[int] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable[_models.SBSubscriptionListResult]: - """List all the subscriptions under a specified topic. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param topic_name: The topic name. - :type topic_name: str - :param skip: Skip is only used if a previous operation returned a partial result. If a previous - response contains a nextLink element, the value of the nextLink element will include a skip - parameter that specifies a starting point to use for subsequent calls. Default value is None. - :type skip: int - :param top: May be used to limit the number of results to the most recent N usageDetails. - Default value is None. - :type top: int - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBSubscriptionListResult or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2022_01_01_preview.models.SBSubscriptionListResult] - :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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBSubscriptionListResult] - - 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_topic_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - topic_name=topic_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - skip=skip, - top=top, - template_url=self.list_by_topic.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - else: - - request = build_list_by_topic_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - topic_name=topic_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - skip=skip, - top=top, - template_url=next_link, - headers=_headers, - params=_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("SBSubscriptionListResult", 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( # 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - - return AsyncItemPaged( - get_next, extract_data - ) - list_by_topic.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions"} # type: ignore - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - subscription_name: str, - parameters: _models.SBSubscription, - **kwargs: Any - ) -> _models.SBSubscription: - """Creates a topic subscription. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param topic_name: The topic name. - :type topic_name: str - :param subscription_name: The subscription name. - :type subscription_name: str - :param parameters: Parameters supplied to create a subscription resource. - :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBSubscription - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBSubscription, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBSubscription - :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-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBSubscription] - - _json = self._serialize.body(parameters, 'SBSubscription') - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - topic_name=topic_name, - subscription_name=subscription_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - 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]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('SBSubscription', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}"} # type: ignore - - - @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - subscription_name: str, - **kwargs: Any - ) -> None: - """Deletes a subscription from the specified topic. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param topic_name: The topic name. - :type topic_name: str - :param subscription_name: The subscription name. - :type subscription_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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - - - request = build_delete_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - topic_name=topic_name, - subscription_name=subscription_name, - subscription_id=self._config.subscription_id, - 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.ErrorResponse, 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.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}"} # type: ignore - - - @distributed_trace_async - async def get( - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - subscription_name: str, - **kwargs: Any - ) -> _models.SBSubscription: - """Returns a subscription description for the specified topic. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param topic_name: The topic name. - :type topic_name: str - :param subscription_name: The subscription name. - :type subscription_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBSubscription, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBSubscription - :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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBSubscription] - - - request = build_get_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - topic_name=topic_name, - subscription_name=subscription_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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('SBSubscription', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}"} # type: ignore - diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/operations/_topics_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/operations/_topics_operations.py deleted file mode 100644 index 02c0592da674c..0000000000000 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/operations/_topics_operations.py +++ /dev/null @@ -1,822 +0,0 @@ -# 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 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.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._topics_operations import build_create_or_update_authorization_rule_request, build_create_or_update_request, build_delete_authorization_rule_request, build_delete_request, build_get_authorization_rule_request, build_get_request, build_list_authorization_rules_request, build_list_by_namespace_request, build_list_keys_request, build_regenerate_keys_request -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class TopicsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.servicebus.v2022_01_01_preview.aio.ServiceBusManagementClient`'s - :attr:`topics` 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_authorization_rules( - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.SBAuthorizationRuleListResult]: - """Gets authorization rules for a topic. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param topic_name: The topic name. - :type topic_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2022_01_01_preview.models.SBAuthorizationRuleListResult] - :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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRuleListResult] - - 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_authorization_rules_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - topic_name=topic_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_authorization_rules.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - else: - - request = build_list_authorization_rules_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - topic_name=topic_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_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("SBAuthorizationRuleListResult", 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( # 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - - return AsyncItemPaged( - get_next, extract_data - ) - list_authorization_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules"} # type: ignore - - @distributed_trace_async - async def create_or_update_authorization_rule( - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - authorization_rule_name: str, - parameters: _models.SBAuthorizationRule, - **kwargs: Any - ) -> _models.SBAuthorizationRule: - """Creates an authorization rule for the specified topic. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param topic_name: The topic name. - :type topic_name: str - :param authorization_rule_name: The authorization rule name. - :type authorization_rule_name: str - :param parameters: The shared access authorization rule. - :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBAuthorizationRule - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBAuthorizationRule - :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-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] - - _json = self._serialize.body(parameters, 'SBAuthorizationRule') - - request = build_create_or_update_authorization_rule_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - topic_name=topic_name, - authorization_rule_name=authorization_rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - template_url=self.create_or_update_authorization_rule.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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create_or_update_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}"} # type: ignore - - - @distributed_trace_async - async def get_authorization_rule( - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - authorization_rule_name: str, - **kwargs: Any - ) -> _models.SBAuthorizationRule: - """Returns the specified authorization rule. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param topic_name: The topic name. - :type topic_name: str - :param authorization_rule_name: The authorization rule name. - :type authorization_rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBAuthorizationRule - :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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] - - - request = build_get_authorization_rule_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - topic_name=topic_name, - authorization_rule_name=authorization_rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get_authorization_rule.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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}"} # type: ignore - - - @distributed_trace_async - async def delete_authorization_rule( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - authorization_rule_name: str, - **kwargs: Any - ) -> None: - """Deletes a topic authorization rule. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param topic_name: The topic name. - :type topic_name: str - :param authorization_rule_name: The authorization rule name. - :type authorization_rule_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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - - - request = build_delete_authorization_rule_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - topic_name=topic_name, - authorization_rule_name=authorization_rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.delete_authorization_rule.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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}"} # type: ignore - - - @distributed_trace_async - async def list_keys( - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - authorization_rule_name: str, - **kwargs: Any - ) -> _models.AccessKeys: - """Gets the primary and secondary connection strings for the topic. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param topic_name: The topic name. - :type topic_name: str - :param authorization_rule_name: The authorization rule name. - :type authorization_rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.AccessKeys - :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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] - - - request = build_list_keys_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - topic_name=topic_name, - authorization_rule_name=authorization_rule_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 - - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('AccessKeys', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/ListKeys"} # type: ignore - - - @distributed_trace_async - async def regenerate_keys( - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - authorization_rule_name: str, - parameters: _models.RegenerateAccessKeyParameters, - **kwargs: Any - ) -> _models.AccessKeys: - """Regenerates primary or secondary connection strings for the topic. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param topic_name: The topic name. - :type topic_name: str - :param authorization_rule_name: The authorization rule name. - :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate the authorization rule. - :type parameters: - ~azure.mgmt.servicebus.v2022_01_01_preview.models.RegenerateAccessKeyParameters - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.AccessKeys - :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-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] - - _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') - - request = build_regenerate_keys_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - topic_name=topic_name, - authorization_rule_name=authorization_rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - template_url=self.regenerate_keys.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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('AccessKeys', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - regenerate_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/regenerateKeys"} # type: ignore - - - @distributed_trace - def list_by_namespace( - self, - resource_group_name: str, - namespace_name: str, - skip: Optional[int] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable[_models.SBTopicListResult]: - """Gets all the topics in a namespace. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param skip: Skip is only used if a previous operation returned a partial result. If a previous - response contains a nextLink element, the value of the nextLink element will include a skip - parameter that specifies a starting point to use for subsequent calls. Default value is None. - :type skip: int - :param top: May be used to limit the number of results to the most recent N usageDetails. - Default value is None. - :type top: int - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBTopicListResult or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2022_01_01_preview.models.SBTopicListResult] - :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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBTopicListResult] - - 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_namespace_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - skip=skip, - top=top, - template_url=self.list_by_namespace.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - else: - - request = build_list_by_namespace_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - skip=skip, - top=top, - template_url=next_link, - headers=_headers, - params=_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("SBTopicListResult", 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( # 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - - return AsyncItemPaged( - get_next, extract_data - ) - list_by_namespace.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics"} # type: ignore - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - parameters: _models.SBTopic, - **kwargs: Any - ) -> _models.SBTopic: - """Creates a topic in the specified namespace. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param topic_name: The topic name. - :type topic_name: str - :param parameters: Parameters supplied to create a topic resource. - :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBTopic - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBTopic, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBTopic - :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-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBTopic] - - _json = self._serialize.body(parameters, 'SBTopic') - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - topic_name=topic_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - 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]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('SBTopic', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}"} # type: ignore - - - @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - **kwargs: Any - ) -> None: - """Deletes a topic from the specified namespace and resource group. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param topic_name: The topic name. - :type topic_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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - - - request = build_delete_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - topic_name=topic_name, - subscription_id=self._config.subscription_id, - 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.ErrorResponse, 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.ServiceBus/namespaces/{namespaceName}/topics/{topicName}"} # type: ignore - - - @distributed_trace_async - async def get( - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - **kwargs: Any - ) -> _models.SBTopic: - """Returns a description for the specified topic. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param topic_name: The topic name. - :type topic_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBTopic, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBTopic - :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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBTopic] - - - request = build_get_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - topic_name=topic_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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('SBTopic', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}"} # type: ignore - diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/models/__init__.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/models/__init__.py deleted file mode 100644 index 21d9474c1ea60..0000000000000 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/models/__init__.py +++ /dev/null @@ -1,171 +0,0 @@ -# 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 AccessKeys -from ._models_py3 import Action -from ._models_py3 import ArmDisasterRecovery -from ._models_py3 import ArmDisasterRecoveryListResult -from ._models_py3 import CheckNameAvailability -from ._models_py3 import CheckNameAvailabilityResult -from ._models_py3 import ConnectionState -from ._models_py3 import CorrelationFilter -from ._models_py3 import Encryption -from ._models_py3 import ErrorAdditionalInfo -from ._models_py3 import ErrorResponse -from ._models_py3 import ErrorResponseError -from ._models_py3 import FailoverProperties -from ._models_py3 import Identity -from ._models_py3 import KeyVaultProperties -from ._models_py3 import MessageCountDetails -from ._models_py3 import MigrationConfigListResult -from ._models_py3 import MigrationConfigProperties -from ._models_py3 import NWRuleSetIpRules -from ._models_py3 import NWRuleSetVirtualNetworkRules -from ._models_py3 import NetworkRuleSet -from ._models_py3 import NetworkRuleSetListResult -from ._models_py3 import Operation -from ._models_py3 import OperationDisplay -from ._models_py3 import OperationListResult -from ._models_py3 import PrivateEndpoint -from ._models_py3 import PrivateEndpointConnection -from ._models_py3 import PrivateEndpointConnectionListResult -from ._models_py3 import PrivateLinkResource -from ._models_py3 import PrivateLinkResourcesListResult -from ._models_py3 import ProxyResource -from ._models_py3 import RegenerateAccessKeyParameters -from ._models_py3 import Resource -from ._models_py3 import ResourceNamespacePatch -from ._models_py3 import Rule -from ._models_py3 import RuleListResult -from ._models_py3 import SBAuthorizationRule -from ._models_py3 import SBAuthorizationRuleListResult -from ._models_py3 import SBClientAffineProperties -from ._models_py3 import SBNamespace -from ._models_py3 import SBNamespaceListResult -from ._models_py3 import SBNamespaceUpdateParameters -from ._models_py3 import SBQueue -from ._models_py3 import SBQueueListResult -from ._models_py3 import SBSku -from ._models_py3 import SBSubscription -from ._models_py3 import SBSubscriptionListResult -from ._models_py3 import SBTopic -from ._models_py3 import SBTopicListResult -from ._models_py3 import SqlFilter -from ._models_py3 import SqlRuleAction -from ._models_py3 import Subnet -from ._models_py3 import SystemData -from ._models_py3 import TrackedResource -from ._models_py3 import UserAssignedIdentity -from ._models_py3 import UserAssignedIdentityProperties - - -from ._service_bus_management_client_enums import ( - AccessRights, - CreatedByType, - DefaultAction, - EndPointProvisioningState, - EntityStatus, - FilterType, - KeySource, - KeyType, - ManagedServiceIdentityType, - MigrationConfigurationName, - NetworkRuleIPAction, - PrivateLinkConnectionStatus, - ProvisioningStateDR, - PublicNetworkAccess, - PublicNetworkAccessFlag, - RoleDisasterRecovery, - SkuName, - SkuTier, - TlsVersion, - UnavailableReason, -) -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__ = [ - 'AccessKeys', - 'Action', - 'ArmDisasterRecovery', - 'ArmDisasterRecoveryListResult', - 'CheckNameAvailability', - 'CheckNameAvailabilityResult', - 'ConnectionState', - 'CorrelationFilter', - 'Encryption', - 'ErrorAdditionalInfo', - 'ErrorResponse', - 'ErrorResponseError', - 'FailoverProperties', - 'Identity', - 'KeyVaultProperties', - 'MessageCountDetails', - 'MigrationConfigListResult', - 'MigrationConfigProperties', - 'NWRuleSetIpRules', - 'NWRuleSetVirtualNetworkRules', - 'NetworkRuleSet', - 'NetworkRuleSetListResult', - 'Operation', - 'OperationDisplay', - 'OperationListResult', - 'PrivateEndpoint', - 'PrivateEndpointConnection', - 'PrivateEndpointConnectionListResult', - 'PrivateLinkResource', - 'PrivateLinkResourcesListResult', - 'ProxyResource', - 'RegenerateAccessKeyParameters', - 'Resource', - 'ResourceNamespacePatch', - 'Rule', - 'RuleListResult', - 'SBAuthorizationRule', - 'SBAuthorizationRuleListResult', - 'SBClientAffineProperties', - 'SBNamespace', - 'SBNamespaceListResult', - 'SBNamespaceUpdateParameters', - 'SBQueue', - 'SBQueueListResult', - 'SBSku', - 'SBSubscription', - 'SBSubscriptionListResult', - 'SBTopic', - 'SBTopicListResult', - 'SqlFilter', - 'SqlRuleAction', - 'Subnet', - 'SystemData', - 'TrackedResource', - 'UserAssignedIdentity', - 'UserAssignedIdentityProperties', - 'AccessRights', - 'CreatedByType', - 'DefaultAction', - 'EndPointProvisioningState', - 'EntityStatus', - 'FilterType', - 'KeySource', - 'KeyType', - 'ManagedServiceIdentityType', - 'MigrationConfigurationName', - 'NetworkRuleIPAction', - 'PrivateLinkConnectionStatus', - 'ProvisioningStateDR', - 'PublicNetworkAccess', - 'PublicNetworkAccessFlag', - 'RoleDisasterRecovery', - 'SkuName', - 'SkuTier', - 'TlsVersion', - 'UnavailableReason', -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/operations/_disaster_recovery_configs_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/operations/_disaster_recovery_configs_operations.py deleted file mode 100644 index 5a2ea424d9b80..0000000000000 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/operations/_disaster_recovery_configs_operations.py +++ /dev/null @@ -1,1212 +0,0 @@ -# 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 msrest import Serializer - -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 .._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, - namespace_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-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs") # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "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_create_or_update_request( - resource_group_name: str, - namespace_name: str, - alias: str, - subscription_id: str, - *, - json: Optional[_models.ArmDisasterRecovery] = None, - content: Any = 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-01-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}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}") # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "alias": _SERIALIZER.url("alias", alias, 'str', max_length=50, min_length=1), - "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="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) - - -def build_delete_request( - resource_group_name: str, - namespace_name: str, - alias: 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-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}") # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "alias": _SERIALIZER.url("alias", alias, 'str', max_length=50, min_length=1), - "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="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) - - -def build_get_request( - resource_group_name: str, - namespace_name: str, - alias: 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-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}") # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "alias": _SERIALIZER.url("alias", alias, 'str', max_length=50, min_length=1), - "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_break_pairing_request( - resource_group_name: str, - namespace_name: str, - alias: 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-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/breakPairing") # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "alias": _SERIALIZER.url("alias", alias, 'str', max_length=50, min_length=1), - "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="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) - - -def build_fail_over_request( - resource_group_name: str, - namespace_name: str, - alias: str, - subscription_id: str, - *, - json: Optional[_models.FailoverProperties] = None, - content: Any = 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-01-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}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/failover") # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "alias": _SERIALIZER.url("alias", alias, 'str', max_length=50, min_length=1), - "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, - json=json, - content=content, - **kwargs - ) - - -def build_list_authorization_rules_request( - resource_group_name: str, - namespace_name: str, - alias: 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-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules") # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "alias": _SERIALIZER.url("alias", alias, 'str', max_length=50, min_length=1), - "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_get_authorization_rule_request( - resource_group_name: str, - namespace_name: str, - alias: str, - authorization_rule_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-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "alias": _SERIALIZER.url("alias", alias, 'str', max_length=50, min_length=1), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "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_keys_request( - resource_group_name: str, - namespace_name: str, - alias: str, - authorization_rule_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-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules/{authorizationRuleName}/listKeys") # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "alias": _SERIALIZER.url("alias", alias, 'str', max_length=50, min_length=1), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "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="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) - - -def build_check_name_availability_request( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - *, - json: Optional[_models.CheckNameAvailability] = None, - content: Any = 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-01-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}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/CheckNameAvailability") # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "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, - json=json, - content=content, - **kwargs - ) - -class DisasterRecoveryConfigsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.servicebus.v2022_01_01_preview.ServiceBusManagementClient`'s - :attr:`disaster_recovery_configs` 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, - namespace_name: str, - **kwargs: Any - ) -> Iterable[_models.ArmDisasterRecoveryListResult]: - """Gets all Alias(Disaster Recovery configurations). - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ArmDisasterRecoveryListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2022_01_01_preview.models.ArmDisasterRecoveryListResult] - :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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ArmDisasterRecoveryListResult] - - 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( - resource_group_name=resource_group_name, - namespace_name=namespace_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 - - else: - - request = build_list_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_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("ArmDisasterRecoveryListResult", 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( # 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs"} # type: ignore - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - namespace_name: str, - alias: str, - parameters: _models.ArmDisasterRecovery, - **kwargs: Any - ) -> Optional[_models.ArmDisasterRecovery]: - """Creates or updates a new Alias(Disaster Recovery configuration). - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param alias: The Disaster Recovery configuration name. - :type alias: str - :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). - :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.ArmDisasterRecovery - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ArmDisasterRecovery, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.ArmDisasterRecovery or None - :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-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ArmDisasterRecovery]] - - _json = self._serialize.body(parameters, 'ArmDisasterRecovery') - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - alias=alias, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('ArmDisasterRecovery', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}"} # type: ignore - - - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - alias: str, - **kwargs: Any - ) -> None: - """Deletes an Alias(Disaster Recovery configuration). - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param alias: The Disaster Recovery configuration name. - :type alias: 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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - - - request = build_delete_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - alias=alias, - subscription_id=self._config.subscription_id, - 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.ErrorResponse, 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.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}"} # type: ignore - - - @distributed_trace - def get( - self, - resource_group_name: str, - namespace_name: str, - alias: str, - **kwargs: Any - ) -> _models.ArmDisasterRecovery: - """Retrieves Alias(Disaster Recovery configuration) for primary or secondary namespace. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param alias: The Disaster Recovery configuration name. - :type alias: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ArmDisasterRecovery, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.ArmDisasterRecovery - :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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ArmDisasterRecovery] - - - request = build_get_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - alias=alias, - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('ArmDisasterRecovery', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}"} # type: ignore - - - @distributed_trace - def break_pairing( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - alias: str, - **kwargs: Any - ) -> None: - """This operation disables the Disaster Recovery and stops replicating changes from primary to - secondary namespaces. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param alias: The Disaster Recovery configuration name. - :type alias: 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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - - - request = build_break_pairing_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - alias=alias, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.break_pairing.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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - break_pairing.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/breakPairing"} # type: ignore - - - @distributed_trace - def fail_over( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - alias: str, - parameters: Optional[_models.FailoverProperties] = None, - **kwargs: Any - ) -> None: - """Invokes GEO DR failover and reconfigure the alias to point to the secondary namespace. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param alias: The Disaster Recovery configuration name. - :type alias: str - :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). - Default value is None. - :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.FailoverProperties - :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 = case_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-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[None] - - if parameters is not None: - _json = self._serialize.body(parameters, 'FailoverProperties') - else: - _json = None - - request = build_fail_over_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - alias=alias, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - template_url=self.fail_over.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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - fail_over.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/failover"} # type: ignore - - - @distributed_trace - def list_authorization_rules( - self, - resource_group_name: str, - namespace_name: str, - alias: str, - **kwargs: Any - ) -> Iterable[_models.SBAuthorizationRuleListResult]: - """Gets the authorization rules for a namespace. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param alias: The Disaster Recovery configuration name. - :type alias: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2022_01_01_preview.models.SBAuthorizationRuleListResult] - :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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRuleListResult] - - 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_authorization_rules_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - alias=alias, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_authorization_rules.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - else: - - request = build_list_authorization_rules_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - alias=alias, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_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("SBAuthorizationRuleListResult", 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( # 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - - return ItemPaged( - get_next, extract_data - ) - list_authorization_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules"} # type: ignore - - @distributed_trace - def get_authorization_rule( - self, - resource_group_name: str, - namespace_name: str, - alias: str, - authorization_rule_name: str, - **kwargs: Any - ) -> _models.SBAuthorizationRule: - """Gets an authorization rule for a namespace by rule name. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param alias: The Disaster Recovery configuration name. - :type alias: str - :param authorization_rule_name: The authorization rule name. - :type authorization_rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBAuthorizationRule - :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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] - - - request = build_get_authorization_rule_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - alias=alias, - authorization_rule_name=authorization_rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get_authorization_rule.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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules/{authorizationRuleName}"} # type: ignore - - - @distributed_trace - def list_keys( - self, - resource_group_name: str, - namespace_name: str, - alias: str, - authorization_rule_name: str, - **kwargs: Any - ) -> _models.AccessKeys: - """Gets the primary and secondary connection strings for the namespace. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param alias: The Disaster Recovery configuration name. - :type alias: str - :param authorization_rule_name: The authorization rule name. - :type authorization_rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.AccessKeys - :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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] - - - request = build_list_keys_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - alias=alias, - authorization_rule_name=authorization_rule_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 - - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('AccessKeys', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules/{authorizationRuleName}/listKeys"} # type: ignore - - - @distributed_trace - def check_name_availability( - self, - resource_group_name: str, - namespace_name: str, - parameters: _models.CheckNameAvailability, - **kwargs: Any - ) -> _models.CheckNameAvailabilityResult: - """Check the give namespace name availability. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param parameters: Parameters to check availability of the given namespace name. - :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.CheckNameAvailability - :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckNameAvailabilityResult, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.CheckNameAvailabilityResult - :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-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.CheckNameAvailabilityResult] - - _json = self._serialize.body(parameters, 'CheckNameAvailability') - - request = build_check_name_availability_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/CheckNameAvailability"} # type: ignore - diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/operations/_migration_configs_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/operations/_migration_configs_operations.py deleted file mode 100644 index 88853ef0f315f..0000000000000 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/operations/_migration_configs_operations.py +++ /dev/null @@ -1,795 +0,0 @@ -# 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, Union, cast - -from msrest import Serializer - -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 .._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, - namespace_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-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations") # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "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_create_and_start_migration_request_initial( - resource_group_name: str, - namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], - subscription_id: str, - *, - json: Optional[_models.MigrationConfigProperties] = None, - content: Any = 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-01-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}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}") # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "configName": _SERIALIZER.url("config_name", config_name, 'str'), - "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="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) - - -def build_delete_request( - resource_group_name: str, - namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], - 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-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}") # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "configName": _SERIALIZER.url("config_name", config_name, 'str'), - "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="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) - - -def build_get_request( - resource_group_name: str, - namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], - 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-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}") # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "configName": _SERIALIZER.url("config_name", config_name, 'str'), - "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_complete_migration_request( - resource_group_name: str, - namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], - 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-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/upgrade") # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "configName": _SERIALIZER.url("config_name", config_name, 'str'), - "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="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) - - -def build_revert_request( - resource_group_name: str, - namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], - 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-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/revert") # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "configName": _SERIALIZER.url("config_name", config_name, 'str'), - "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="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) - -class MigrationConfigsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.servicebus.v2022_01_01_preview.ServiceBusManagementClient`'s - :attr:`migration_configs` 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, - namespace_name: str, - **kwargs: Any - ) -> Iterable[_models.MigrationConfigListResult]: - """Gets all migrationConfigurations. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MigrationConfigListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2022_01_01_preview.models.MigrationConfigListResult] - :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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MigrationConfigListResult] - - 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( - resource_group_name=resource_group_name, - namespace_name=namespace_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 - - else: - - request = build_list_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_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("MigrationConfigListResult", 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( # 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations"} # type: ignore - - def _create_and_start_migration_initial( - self, - resource_group_name: str, - namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], - parameters: _models.MigrationConfigProperties, - **kwargs: Any - ) -> Optional[_models.MigrationConfigProperties]: - 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-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.MigrationConfigProperties]] - - _json = self._serialize.body(parameters, 'MigrationConfigProperties') - - request = build_create_and_start_migration_request_initial( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - config_name=config_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - template_url=self._create_and_start_migration_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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('MigrationConfigProperties', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _create_and_start_migration_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}"} # type: ignore - - - @distributed_trace - def begin_create_and_start_migration( - self, - resource_group_name: str, - namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], - parameters: _models.MigrationConfigProperties, - **kwargs: Any - ) -> LROPoller[_models.MigrationConfigProperties]: - """Creates Migration configuration and starts migration of entities from Standard to Premium - namespace. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". - :type config_name: str or - ~azure.mgmt.servicebus.v2022_01_01_preview.models.MigrationConfigurationName - :param parameters: Parameters required to create Migration Configuration. - :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.MigrationConfigProperties - :keyword callable cls: A custom type 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 MigrationConfigProperties or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.servicebus.v2022_01_01_preview.models.MigrationConfigProperties] - :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-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.MigrationConfigProperties] - 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_and_start_migration_initial( # type: ignore - resource_group_name=resource_group_name, - namespace_name=namespace_name, - config_name=config_name, - parameters=parameters, - 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('MigrationConfigProperties', 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_and_start_migration.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}"} # type: ignore - - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], - **kwargs: Any - ) -> None: - """Deletes a MigrationConfiguration. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". - :type config_name: str or - ~azure.mgmt.servicebus.v2022_01_01_preview.models.MigrationConfigurationName - :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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - - - request = build_delete_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - config_name=config_name, - subscription_id=self._config.subscription_id, - 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.ErrorResponse, 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.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}"} # type: ignore - - - @distributed_trace - def get( - self, - resource_group_name: str, - namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], - **kwargs: Any - ) -> _models.MigrationConfigProperties: - """Retrieves Migration Config. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". - :type config_name: str or - ~azure.mgmt.servicebus.v2022_01_01_preview.models.MigrationConfigurationName - :keyword callable cls: A custom type or function that will be passed the direct response - :return: MigrationConfigProperties, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.MigrationConfigProperties - :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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MigrationConfigProperties] - - - request = build_get_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - config_name=config_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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('MigrationConfigProperties', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}"} # type: ignore - - - @distributed_trace - def complete_migration( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], - **kwargs: Any - ) -> None: - """This operation Completes Migration of entities by pointing the connection strings to Premium - namespace and any entities created after the operation will be under Premium Namespace. - CompleteMigration operation will fail when entity migration is in-progress. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". - :type config_name: str or - ~azure.mgmt.servicebus.v2022_01_01_preview.models.MigrationConfigurationName - :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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - - - request = build_complete_migration_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - config_name=config_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.complete_migration.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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - complete_migration.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/upgrade"} # type: ignore - - - @distributed_trace - def revert( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], - **kwargs: Any - ) -> None: - """This operation reverts Migration. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". - :type config_name: str or - ~azure.mgmt.servicebus.v2022_01_01_preview.models.MigrationConfigurationName - :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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - - - request = build_revert_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - config_name=config_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.revert.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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - revert.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/revert"} # type: ignore - diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/operations/_namespaces_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/operations/_namespaces_operations.py deleted file mode 100644 index 5ca6dab57a1b6..0000000000000 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/operations/_namespaces_operations.py +++ /dev/null @@ -1,1994 +0,0 @@ -# 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, Union, cast - -from msrest import Serializer - -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 .._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( - 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-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/namespaces") - 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-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces") # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "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_create_or_update_request_initial( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - *, - json: Optional[_models.SBNamespace] = None, - content: Any = 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-01-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}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}") # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str'), - "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="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) - - -def build_delete_request_initial( - resource_group_name: str, - namespace_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-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}") # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "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="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) - - -def build_get_request( - resource_group_name: str, - namespace_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-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}") # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "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_update_request( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - *, - json: Optional[_models.SBNamespaceUpdateParameters] = None, - content: Any = 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-01-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}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}") # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "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="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) - - -def build_create_or_update_network_rule_set_request( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - *, - json: Optional[_models.NetworkRuleSet] = None, - content: Any = 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-01-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}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default") # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "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="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) - - -def build_get_network_rule_set_request( - resource_group_name: str, - namespace_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-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default") # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "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_network_rule_sets_request( - resource_group_name: str, - namespace_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-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets") # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "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_authorization_rules_request( - resource_group_name: str, - namespace_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-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules") # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "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_create_or_update_authorization_rule_request( - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - subscription_id: str, - *, - json: Optional[_models.SBAuthorizationRule] = None, - content: Any = 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-01-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}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "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="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) - - -def build_delete_authorization_rule_request( - resource_group_name: str, - namespace_name: str, - authorization_rule_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-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "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="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) - - -def build_get_authorization_rule_request( - resource_group_name: str, - namespace_name: str, - authorization_rule_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-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "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_keys_request( - resource_group_name: str, - namespace_name: str, - authorization_rule_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-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/listKeys") # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "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="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) - - -def build_regenerate_keys_request( - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - subscription_id: str, - *, - json: Optional[_models.RegenerateAccessKeyParameters] = None, - content: Any = 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-01-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}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/regenerateKeys") # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "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, - json=json, - content=content, - **kwargs - ) - - -def build_check_name_availability_request( - subscription_id: str, - *, - json: Optional[_models.CheckNameAvailability] = None, - content: Any = 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-01-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.ServiceBus/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, - json=json, - content=content, - **kwargs - ) - -class NamespacesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.servicebus.v2022_01_01_preview.ServiceBusManagementClient`'s - :attr:`namespaces` 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.SBNamespaceListResult]: - """Gets all the available namespaces within the subscription, irrespective of the resource groups. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBNamespaceListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2022_01_01_preview.models.SBNamespaceListResult] - :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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBNamespaceListResult] - - 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( - 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 - - else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_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("SBNamespaceListResult", 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( # 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/namespaces"} # type: ignore - - @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable[_models.SBNamespaceListResult]: - """Gets the available namespaces within a resource group. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :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 SBNamespaceListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2022_01_01_preview.models.SBNamespaceListResult] - :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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBNamespaceListResult] - - 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: - - 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=next_link, - headers=_headers, - params=_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("SBNamespaceListResult", 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( # 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.ErrorResponse, 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.ServiceBus/namespaces"} # type: ignore - - def _create_or_update_initial( - self, - resource_group_name: str, - namespace_name: str, - parameters: _models.SBNamespace, - **kwargs: Any - ) -> Optional[_models.SBNamespace]: - 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-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.SBNamespace]] - - _json = self._serialize.body(parameters, 'SBNamespace') - - request = build_create_or_update_request_initial( - resource_group_name=resource_group_name, - namespace_name=namespace_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'], - 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, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('SBNamespace', pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize('SBNamespace', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore - - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - namespace_name: str, - parameters: _models.SBNamespace, - **kwargs: Any - ) -> LROPoller[_models.SBNamespace]: - """Creates or updates a service namespace. Once created, this namespace's resource manifest is - immutable. This operation is idempotent. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param parameters: Parameters supplied to create a namespace resource. - :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBNamespace - :keyword callable cls: A custom type 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 SBNamespace or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.servicebus.v2022_01_01_preview.models.SBNamespace] - :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-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBNamespace] - 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, - namespace_name=namespace_name, - parameters=parameters, - 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('SBNamespace', 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.ServiceBus/namespaces/{namespaceName}"} # type: ignore - - def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) 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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - - - request = build_delete_request_initial( - resource_group_name=resource_group_name, - namespace_name=namespace_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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore - - - @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> LROPoller[None]: - """Deletes an existing namespace. This operation also removes all associated resources under the - namespace. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_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 None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :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-01-01-preview")) # type: 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._delete_initial( # type: ignore - resource_group_name=resource_group_name, - namespace_name=namespace_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): - 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_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore - - @distributed_trace - def get( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> _models.SBNamespace: - """Gets a description for the specified namespace. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBNamespace, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBNamespace - :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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBNamespace] - - - request = build_get_request( - resource_group_name=resource_group_name, - namespace_name=namespace_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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('SBNamespace', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore - - - @distributed_trace - def update( - self, - resource_group_name: str, - namespace_name: str, - parameters: _models.SBNamespaceUpdateParameters, - **kwargs: Any - ) -> Optional[_models.SBNamespace]: - """Updates a service namespace. Once created, this namespace's resource manifest is immutable. - This operation is idempotent. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param parameters: Parameters supplied to update a namespace resource. - :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBNamespaceUpdateParameters - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBNamespace, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBNamespace or None - :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-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.SBNamespace]] - - _json = self._serialize.body(parameters, 'SBNamespaceUpdateParameters') - - request = build_update_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - template_url=self.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, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('SBNamespace', pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize('SBNamespace', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore - - - @distributed_trace - def create_or_update_network_rule_set( - self, - resource_group_name: str, - namespace_name: str, - parameters: _models.NetworkRuleSet, - **kwargs: Any - ) -> _models.NetworkRuleSet: - """Create or update NetworkRuleSet for a Namespace. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param parameters: The Namespace IpFilterRule. - :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.NetworkRuleSet - :keyword callable cls: A custom type or function that will be passed the direct response - :return: NetworkRuleSet, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.NetworkRuleSet - :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-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.NetworkRuleSet] - - _json = self._serialize.body(parameters, 'NetworkRuleSet') - - request = build_create_or_update_network_rule_set_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - template_url=self.create_or_update_network_rule_set.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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('NetworkRuleSet', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create_or_update_network_rule_set.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default"} # type: ignore - - - @distributed_trace - def get_network_rule_set( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> _models.NetworkRuleSet: - """Gets NetworkRuleSet for a Namespace. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: NetworkRuleSet, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.NetworkRuleSet - :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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.NetworkRuleSet] - - - request = build_get_network_rule_set_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get_network_rule_set.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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('NetworkRuleSet', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_network_rule_set.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default"} # type: ignore - - - @distributed_trace - def list_network_rule_sets( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> Iterable[_models.NetworkRuleSetListResult]: - """Gets list of NetworkRuleSet for a Namespace. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either NetworkRuleSetListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2022_01_01_preview.models.NetworkRuleSetListResult] - :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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.NetworkRuleSetListResult] - - 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_network_rule_sets_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_network_rule_sets.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - else: - - request = build_list_network_rule_sets_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_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("NetworkRuleSetListResult", 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( # 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - - return ItemPaged( - get_next, extract_data - ) - list_network_rule_sets.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets"} # type: ignore - - @distributed_trace - def list_authorization_rules( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> Iterable[_models.SBAuthorizationRuleListResult]: - """Gets the authorization rules for a namespace. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2022_01_01_preview.models.SBAuthorizationRuleListResult] - :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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRuleListResult] - - 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_authorization_rules_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_authorization_rules.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - else: - - request = build_list_authorization_rules_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_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("SBAuthorizationRuleListResult", 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( # 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - - return ItemPaged( - get_next, extract_data - ) - list_authorization_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules"} # type: ignore - - @distributed_trace - def create_or_update_authorization_rule( - self, - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - parameters: _models.SBAuthorizationRule, - **kwargs: Any - ) -> _models.SBAuthorizationRule: - """Creates or updates an authorization rule for a namespace. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param authorization_rule_name: The authorization rule name. - :type authorization_rule_name: str - :param parameters: The shared access authorization rule. - :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBAuthorizationRule - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBAuthorizationRule - :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-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] - - _json = self._serialize.body(parameters, 'SBAuthorizationRule') - - request = build_create_or_update_authorization_rule_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - authorization_rule_name=authorization_rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - template_url=self.create_or_update_authorization_rule.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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create_or_update_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}"} # type: ignore - - - @distributed_trace - def delete_authorization_rule( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - **kwargs: Any - ) -> None: - """Deletes a namespace authorization rule. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param authorization_rule_name: The authorization rule name. - :type authorization_rule_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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - - - request = build_delete_authorization_rule_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - authorization_rule_name=authorization_rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.delete_authorization_rule.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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}"} # type: ignore - - - @distributed_trace - def get_authorization_rule( - self, - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - **kwargs: Any - ) -> _models.SBAuthorizationRule: - """Gets an authorization rule for a namespace by rule name. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param authorization_rule_name: The authorization rule name. - :type authorization_rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBAuthorizationRule - :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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] - - - request = build_get_authorization_rule_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - authorization_rule_name=authorization_rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get_authorization_rule.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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}"} # type: ignore - - - @distributed_trace - def list_keys( - self, - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - **kwargs: Any - ) -> _models.AccessKeys: - """Gets the primary and secondary connection strings for the namespace. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param authorization_rule_name: The authorization rule name. - :type authorization_rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.AccessKeys - :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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] - - - request = build_list_keys_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - authorization_rule_name=authorization_rule_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 - - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('AccessKeys', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/listKeys"} # type: ignore - - - @distributed_trace - def regenerate_keys( - self, - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - parameters: _models.RegenerateAccessKeyParameters, - **kwargs: Any - ) -> _models.AccessKeys: - """Regenerates the primary or secondary connection strings for the namespace. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param authorization_rule_name: The authorization rule name. - :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate the authorization rule. - :type parameters: - ~azure.mgmt.servicebus.v2022_01_01_preview.models.RegenerateAccessKeyParameters - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.AccessKeys - :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-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] - - _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') - - request = build_regenerate_keys_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - authorization_rule_name=authorization_rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - template_url=self.regenerate_keys.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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('AccessKeys', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - regenerate_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/regenerateKeys"} # type: ignore - - - @distributed_trace - def check_name_availability( - self, - parameters: _models.CheckNameAvailability, - **kwargs: Any - ) -> _models.CheckNameAvailabilityResult: - """Check the give namespace name availability. - - :param parameters: Parameters to check availability of the given namespace name. - :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.CheckNameAvailability - :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckNameAvailabilityResult, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.CheckNameAvailabilityResult - :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-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.CheckNameAvailabilityResult] - - _json = self._serialize.body(parameters, 'CheckNameAvailability') - - 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'], - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/CheckNameAvailability"} # type: ignore - diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/operations/_patch.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/operations/_patch.py deleted file mode 100644 index 0ad201a8c586e..0000000000000 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/operations/_patch.py +++ /dev/null @@ -1,19 +0,0 @@ -# ------------------------------------ -# 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/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/operations/_private_endpoint_connections_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/operations/_private_endpoint_connections_operations.py deleted file mode 100644 index f7b46b8fcdbf9..0000000000000 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/operations/_private_endpoint_connections_operations.py +++ /dev/null @@ -1,579 +0,0 @@ -# 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, Union, cast - -from msrest import Serializer - -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 .._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, - namespace_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-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections") # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "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_create_or_update_request( - subscription_id: str, - resource_group_name: str, - namespace_name: str, - private_endpoint_connection_name: str, - *, - json: Optional[_models.PrivateEndpointConnection] = None, - content: Any = 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-01-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}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/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', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "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, - json=json, - content=content, - **kwargs - ) - - -def build_delete_request_initial( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - private_endpoint_connection_name: 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-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, '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 - ) - - -def build_get_request( - resource_group_name: str, - namespace_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-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - "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 PrivateEndpointConnectionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.servicebus.v2022_01_01_preview.ServiceBusManagementClient`'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, - namespace_name: str, - **kwargs: Any - ) -> Iterable[_models.PrivateEndpointConnectionListResult]: - """Gets the available PrivateEndpointConnections within a namespace. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateEndpointConnectionListResult or the result - of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2022_01_01_preview.models.PrivateEndpointConnectionListResult] - :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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnectionListResult] - - 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( - resource_group_name=resource_group_name, - namespace_name=namespace_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 - - else: - - request = build_list_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_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("PrivateEndpointConnectionListResult", 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( # 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections"} # type: ignore - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - namespace_name: str, - private_endpoint_connection_name: str, - parameters: _models.PrivateEndpointConnection, - **kwargs: Any - ) -> _models.PrivateEndpointConnection: - """Creates or updates PrivateEndpointConnections of service namespace. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param private_endpoint_connection_name: The PrivateEndpointConnection name. - :type private_endpoint_connection_name: str - :param parameters: Parameters supplied to update Status of PrivateEndPoint Connection to - namespace resource. - :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.PrivateEndpointConnection - :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.servicebus.v2022_01_01_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 = case_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-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] - - _json = self._serialize.body(parameters, 'PrivateEndpointConnection') - - request = build_create_or_update_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - namespace_name=namespace_name, - private_endpoint_connection_name=private_endpoint_connection_name, - api_version=api_version, - content_type=content_type, - json=_json, - 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, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - - - def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - private_endpoint_connection_name: str, - **kwargs: Any - ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) 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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - - - request = build_delete_request_initial( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - private_endpoint_connection_name=private_endpoint_connection_name, - 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - - - @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - private_endpoint_connection_name: str, - **kwargs: Any - ) -> LROPoller[None]: - """Deletes an existing Private Endpoint Connection. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param private_endpoint_connection_name: The PrivateEndpointConnection name. - :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 None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :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-01-01-preview")) # type: 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._delete_initial( # type: ignore - resource_group_name=resource_group_name, - namespace_name=namespace_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): - 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_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - - @distributed_trace - def get( - self, - resource_group_name: str, - namespace_name: str, - private_endpoint_connection_name: str, - **kwargs: Any - ) -> _models.PrivateEndpointConnection: - """Gets a description for the specified Private Endpoint Connection. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param private_endpoint_connection_name: The PrivateEndpointConnection name. - :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.servicebus.v2022_01_01_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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] - - - request = build_get_request( - resource_group_name=resource_group_name, - namespace_name=namespace_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.ErrorResponse, 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.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/operations/_queues_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/operations/_queues_operations.py deleted file mode 100644 index 05c04c8b4fc54..0000000000000 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/operations/_queues_operations.py +++ /dev/null @@ -1,1253 +0,0 @@ -# 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 msrest import Serializer - -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 .._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_authorization_rules_request( - resource_group_name: str, - namespace_name: str, - queue_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-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules") # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', min_length=1), - "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_create_or_update_authorization_rule_request( - resource_group_name: str, - namespace_name: str, - queue_name: str, - authorization_rule_name: str, - subscription_id: str, - *, - json: Optional[_models.SBAuthorizationRule] = None, - content: Any = 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-01-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}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', min_length=1), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "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="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) - - -def build_delete_authorization_rule_request( - resource_group_name: str, - namespace_name: str, - queue_name: str, - authorization_rule_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-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', min_length=1), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "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="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) - - -def build_get_authorization_rule_request( - resource_group_name: str, - namespace_name: str, - queue_name: str, - authorization_rule_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-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', min_length=1), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "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_keys_request( - resource_group_name: str, - namespace_name: str, - queue_name: str, - authorization_rule_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-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/ListKeys") # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', min_length=1), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "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="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) - - -def build_regenerate_keys_request( - resource_group_name: str, - namespace_name: str, - queue_name: str, - authorization_rule_name: str, - subscription_id: str, - *, - json: Optional[_models.RegenerateAccessKeyParameters] = None, - content: Any = 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-01-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}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/regenerateKeys") # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', min_length=1), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "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, - json=json, - content=content, - **kwargs - ) - - -def build_list_by_namespace_request( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - *, - skip: Optional[int] = None, - top: Optional[int] = 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-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues") # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "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') - if skip is not None: - _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', maximum=1000, minimum=0) - if top is not None: - _params['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) - - # 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, - namespace_name: str, - queue_name: str, - subscription_id: str, - *, - json: Optional[_models.SBQueue] = None, - content: Any = 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-01-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}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}") # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', min_length=1), - "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="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) - - -def build_delete_request( - resource_group_name: str, - namespace_name: str, - queue_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-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}") # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', min_length=1), - "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="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) - - -def build_get_request( - resource_group_name: str, - namespace_name: str, - queue_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-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}") # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', min_length=1), - "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 QueuesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.servicebus.v2022_01_01_preview.ServiceBusManagementClient`'s - :attr:`queues` 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_authorization_rules( - self, - resource_group_name: str, - namespace_name: str, - queue_name: str, - **kwargs: Any - ) -> Iterable[_models.SBAuthorizationRuleListResult]: - """Gets all authorization rules for a queue. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param queue_name: The queue name. - :type queue_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2022_01_01_preview.models.SBAuthorizationRuleListResult] - :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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRuleListResult] - - 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_authorization_rules_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - queue_name=queue_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_authorization_rules.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - else: - - request = build_list_authorization_rules_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - queue_name=queue_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_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("SBAuthorizationRuleListResult", 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( # 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - - return ItemPaged( - get_next, extract_data - ) - list_authorization_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules"} # type: ignore - - @distributed_trace - def create_or_update_authorization_rule( - self, - resource_group_name: str, - namespace_name: str, - queue_name: str, - authorization_rule_name: str, - parameters: _models.SBAuthorizationRule, - **kwargs: Any - ) -> _models.SBAuthorizationRule: - """Creates an authorization rule for a queue. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param queue_name: The queue name. - :type queue_name: str - :param authorization_rule_name: The authorization rule name. - :type authorization_rule_name: str - :param parameters: The shared access authorization rule. - :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBAuthorizationRule - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBAuthorizationRule - :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-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] - - _json = self._serialize.body(parameters, 'SBAuthorizationRule') - - request = build_create_or_update_authorization_rule_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - queue_name=queue_name, - authorization_rule_name=authorization_rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - template_url=self.create_or_update_authorization_rule.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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create_or_update_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}"} # type: ignore - - - @distributed_trace - def delete_authorization_rule( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - queue_name: str, - authorization_rule_name: str, - **kwargs: Any - ) -> None: - """Deletes a queue authorization rule. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param queue_name: The queue name. - :type queue_name: str - :param authorization_rule_name: The authorization rule name. - :type authorization_rule_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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - - - request = build_delete_authorization_rule_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - queue_name=queue_name, - authorization_rule_name=authorization_rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.delete_authorization_rule.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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}"} # type: ignore - - - @distributed_trace - def get_authorization_rule( - self, - resource_group_name: str, - namespace_name: str, - queue_name: str, - authorization_rule_name: str, - **kwargs: Any - ) -> _models.SBAuthorizationRule: - """Gets an authorization rule for a queue by rule name. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param queue_name: The queue name. - :type queue_name: str - :param authorization_rule_name: The authorization rule name. - :type authorization_rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBAuthorizationRule - :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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] - - - request = build_get_authorization_rule_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - queue_name=queue_name, - authorization_rule_name=authorization_rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get_authorization_rule.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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}"} # type: ignore - - - @distributed_trace - def list_keys( - self, - resource_group_name: str, - namespace_name: str, - queue_name: str, - authorization_rule_name: str, - **kwargs: Any - ) -> _models.AccessKeys: - """Primary and secondary connection strings to the queue. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param queue_name: The queue name. - :type queue_name: str - :param authorization_rule_name: The authorization rule name. - :type authorization_rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.AccessKeys - :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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] - - - request = build_list_keys_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - queue_name=queue_name, - authorization_rule_name=authorization_rule_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 - - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('AccessKeys', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/ListKeys"} # type: ignore - - - @distributed_trace - def regenerate_keys( - self, - resource_group_name: str, - namespace_name: str, - queue_name: str, - authorization_rule_name: str, - parameters: _models.RegenerateAccessKeyParameters, - **kwargs: Any - ) -> _models.AccessKeys: - """Regenerates the primary or secondary connection strings to the queue. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param queue_name: The queue name. - :type queue_name: str - :param authorization_rule_name: The authorization rule name. - :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate the authorization rule. - :type parameters: - ~azure.mgmt.servicebus.v2022_01_01_preview.models.RegenerateAccessKeyParameters - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.AccessKeys - :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-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] - - _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') - - request = build_regenerate_keys_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - queue_name=queue_name, - authorization_rule_name=authorization_rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - template_url=self.regenerate_keys.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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('AccessKeys', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - regenerate_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/regenerateKeys"} # type: ignore - - - @distributed_trace - def list_by_namespace( - self, - resource_group_name: str, - namespace_name: str, - skip: Optional[int] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable[_models.SBQueueListResult]: - """Gets the queues within a namespace. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param skip: Skip is only used if a previous operation returned a partial result. If a previous - response contains a nextLink element, the value of the nextLink element will include a skip - parameter that specifies a starting point to use for subsequent calls. Default value is None. - :type skip: int - :param top: May be used to limit the number of results to the most recent N usageDetails. - Default value is None. - :type top: int - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBQueueListResult or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2022_01_01_preview.models.SBQueueListResult] - :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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBQueueListResult] - - 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_namespace_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - skip=skip, - top=top, - template_url=self.list_by_namespace.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - else: - - request = build_list_by_namespace_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - skip=skip, - top=top, - template_url=next_link, - headers=_headers, - params=_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("SBQueueListResult", 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( # 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - - return ItemPaged( - get_next, extract_data - ) - list_by_namespace.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues"} # type: ignore - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - namespace_name: str, - queue_name: str, - parameters: _models.SBQueue, - **kwargs: Any - ) -> _models.SBQueue: - """Creates or updates a Service Bus queue. This operation is idempotent. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param queue_name: The queue name. - :type queue_name: str - :param parameters: Parameters supplied to create or update a queue resource. - :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBQueue - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBQueue, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBQueue - :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-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBQueue] - - _json = self._serialize.body(parameters, 'SBQueue') - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - queue_name=queue_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - 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]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('SBQueue', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}"} # type: ignore - - - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - queue_name: str, - **kwargs: Any - ) -> None: - """Deletes a queue from the specified namespace in a resource group. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param queue_name: The queue name. - :type queue_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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - - - request = build_delete_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - queue_name=queue_name, - subscription_id=self._config.subscription_id, - 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.ErrorResponse, 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.ServiceBus/namespaces/{namespaceName}/queues/{queueName}"} # type: ignore - - - @distributed_trace - def get( - self, - resource_group_name: str, - namespace_name: str, - queue_name: str, - **kwargs: Any - ) -> _models.SBQueue: - """Returns a description for the specified queue. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param queue_name: The queue name. - :type queue_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBQueue, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBQueue - :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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBQueue] - - - request = build_get_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - queue_name=queue_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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('SBQueue', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}"} # type: ignore - diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/operations/_rules_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/operations/_rules_operations.py deleted file mode 100644 index 2a90c85ff18ec..0000000000000 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/operations/_rules_operations.py +++ /dev/null @@ -1,576 +0,0 @@ -# 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 msrest import Serializer - -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 .._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_subscriptions_request( - resource_group_name: str, - namespace_name: str, - topic_name: str, - subscription_name: str, - subscription_id: str, - *, - skip: Optional[int] = None, - top: Optional[int] = 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-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules") # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - "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') - if skip is not None: - _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', maximum=1000, minimum=0) - if top is not None: - _params['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) - - # 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, - namespace_name: str, - topic_name: str, - subscription_name: str, - rule_name: str, - subscription_id: str, - *, - json: Optional[_models.Rule] = None, - content: Any = 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-01-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}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}") # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - "ruleName": _SERIALIZER.url("rule_name", rule_name, 'str', max_length=50, min_length=1), - "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="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) - - -def build_delete_request( - resource_group_name: str, - namespace_name: str, - topic_name: str, - subscription_name: str, - rule_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-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}") # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - "ruleName": _SERIALIZER.url("rule_name", rule_name, 'str', max_length=50, min_length=1), - "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="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) - - -def build_get_request( - resource_group_name: str, - namespace_name: str, - topic_name: str, - subscription_name: str, - rule_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-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}") # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - "ruleName": _SERIALIZER.url("rule_name", rule_name, 'str', max_length=50, min_length=1), - "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 RulesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.servicebus.v2022_01_01_preview.ServiceBusManagementClient`'s - :attr:`rules` 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_subscriptions( - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - subscription_name: str, - skip: Optional[int] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable[_models.RuleListResult]: - """List all the rules within given topic-subscription. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param topic_name: The topic name. - :type topic_name: str - :param subscription_name: The subscription name. - :type subscription_name: str - :param skip: Skip is only used if a previous operation returned a partial result. If a previous - response contains a nextLink element, the value of the nextLink element will include a skip - parameter that specifies a starting point to use for subsequent calls. Default value is None. - :type skip: int - :param top: May be used to limit the number of results to the most recent N usageDetails. - Default value is None. - :type top: int - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RuleListResult or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2022_01_01_preview.models.RuleListResult] - :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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.RuleListResult] - - 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_subscriptions_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - topic_name=topic_name, - subscription_name=subscription_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - skip=skip, - top=top, - template_url=self.list_by_subscriptions.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - else: - - request = build_list_by_subscriptions_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - topic_name=topic_name, - subscription_name=subscription_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - skip=skip, - top=top, - template_url=next_link, - headers=_headers, - params=_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("RuleListResult", 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( # 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - - return ItemPaged( - get_next, extract_data - ) - list_by_subscriptions.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules"} # type: ignore - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - subscription_name: str, - rule_name: str, - parameters: _models.Rule, - **kwargs: Any - ) -> _models.Rule: - """Creates a new rule and updates an existing rule. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param topic_name: The topic name. - :type topic_name: str - :param subscription_name: The subscription name. - :type subscription_name: str - :param rule_name: The rule name. - :type rule_name: str - :param parameters: Parameters supplied to create a rule. - :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.Rule - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Rule, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.Rule - :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-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.Rule] - - _json = self._serialize.body(parameters, 'Rule') - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - topic_name=topic_name, - subscription_name=subscription_name, - rule_name=rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - 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]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('Rule', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}"} # type: ignore - - - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - subscription_name: str, - rule_name: str, - **kwargs: Any - ) -> None: - """Deletes an existing rule. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param topic_name: The topic name. - :type topic_name: str - :param subscription_name: The subscription name. - :type subscription_name: str - :param rule_name: The rule name. - :type rule_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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - - - request = build_delete_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - topic_name=topic_name, - subscription_name=subscription_name, - rule_name=rule_name, - subscription_id=self._config.subscription_id, - 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.ErrorResponse, 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.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}"} # type: ignore - - - @distributed_trace - def get( - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - subscription_name: str, - rule_name: str, - **kwargs: Any - ) -> _models.Rule: - """Retrieves the description for the specified rule. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param topic_name: The topic name. - :type topic_name: str - :param subscription_name: The subscription name. - :type subscription_name: str - :param rule_name: The rule name. - :type rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Rule, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.Rule - :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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Rule] - - - request = build_get_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - topic_name=topic_name, - subscription_name=subscription_name, - rule_name=rule_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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('Rule', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}"} # type: ignore - diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/operations/_subscriptions_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/operations/_subscriptions_operations.py deleted file mode 100644 index 36d423236c754..0000000000000 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/operations/_subscriptions_operations.py +++ /dev/null @@ -1,552 +0,0 @@ -# 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 msrest import Serializer - -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 .._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_topic_request( - resource_group_name: str, - namespace_name: str, - topic_name: str, - subscription_id: str, - *, - skip: Optional[int] = None, - top: Optional[int] = 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-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions") # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "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') - if skip is not None: - _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', maximum=1000, minimum=0) - if top is not None: - _params['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) - - # 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, - namespace_name: str, - topic_name: str, - subscription_name: str, - subscription_id: str, - *, - json: Optional[_models.SBSubscription] = None, - content: Any = 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-01-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}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}") # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - "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="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) - - -def build_delete_request( - resource_group_name: str, - namespace_name: str, - topic_name: str, - subscription_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-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}") # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - "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="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) - - -def build_get_request( - resource_group_name: str, - namespace_name: str, - topic_name: str, - subscription_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-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}") # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - "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 SubscriptionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.servicebus.v2022_01_01_preview.ServiceBusManagementClient`'s - :attr:`subscriptions` 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_topic( - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - skip: Optional[int] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable[_models.SBSubscriptionListResult]: - """List all the subscriptions under a specified topic. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param topic_name: The topic name. - :type topic_name: str - :param skip: Skip is only used if a previous operation returned a partial result. If a previous - response contains a nextLink element, the value of the nextLink element will include a skip - parameter that specifies a starting point to use for subsequent calls. Default value is None. - :type skip: int - :param top: May be used to limit the number of results to the most recent N usageDetails. - Default value is None. - :type top: int - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBSubscriptionListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2022_01_01_preview.models.SBSubscriptionListResult] - :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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBSubscriptionListResult] - - 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_topic_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - topic_name=topic_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - skip=skip, - top=top, - template_url=self.list_by_topic.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - else: - - request = build_list_by_topic_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - topic_name=topic_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - skip=skip, - top=top, - template_url=next_link, - headers=_headers, - params=_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("SBSubscriptionListResult", 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( # 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - - return ItemPaged( - get_next, extract_data - ) - list_by_topic.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions"} # type: ignore - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - subscription_name: str, - parameters: _models.SBSubscription, - **kwargs: Any - ) -> _models.SBSubscription: - """Creates a topic subscription. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param topic_name: The topic name. - :type topic_name: str - :param subscription_name: The subscription name. - :type subscription_name: str - :param parameters: Parameters supplied to create a subscription resource. - :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBSubscription - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBSubscription, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBSubscription - :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-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBSubscription] - - _json = self._serialize.body(parameters, 'SBSubscription') - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - topic_name=topic_name, - subscription_name=subscription_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - 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]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('SBSubscription', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}"} # type: ignore - - - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - subscription_name: str, - **kwargs: Any - ) -> None: - """Deletes a subscription from the specified topic. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param topic_name: The topic name. - :type topic_name: str - :param subscription_name: The subscription name. - :type subscription_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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - - - request = build_delete_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - topic_name=topic_name, - subscription_name=subscription_name, - subscription_id=self._config.subscription_id, - 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.ErrorResponse, 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.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}"} # type: ignore - - - @distributed_trace - def get( - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - subscription_name: str, - **kwargs: Any - ) -> _models.SBSubscription: - """Returns a subscription description for the specified topic. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param topic_name: The topic name. - :type topic_name: str - :param subscription_name: The subscription name. - :type subscription_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBSubscription, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBSubscription - :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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBSubscription] - - - request = build_get_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - topic_name=topic_name, - subscription_name=subscription_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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('SBSubscription', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}"} # type: ignore - diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/operations/_topics_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/operations/_topics_operations.py deleted file mode 100644 index b22c057aba161..0000000000000 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/operations/_topics_operations.py +++ /dev/null @@ -1,1253 +0,0 @@ -# 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 msrest import Serializer - -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 .._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_authorization_rules_request( - resource_group_name: str, - namespace_name: str, - topic_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-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules") # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "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_create_or_update_authorization_rule_request( - resource_group_name: str, - namespace_name: str, - topic_name: str, - authorization_rule_name: str, - subscription_id: str, - *, - json: Optional[_models.SBAuthorizationRule] = None, - content: Any = 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-01-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}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "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="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) - - -def build_get_authorization_rule_request( - resource_group_name: str, - namespace_name: str, - topic_name: str, - authorization_rule_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-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "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_delete_authorization_rule_request( - resource_group_name: str, - namespace_name: str, - topic_name: str, - authorization_rule_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-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "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="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) - - -def build_list_keys_request( - resource_group_name: str, - namespace_name: str, - topic_name: str, - authorization_rule_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-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/ListKeys") # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "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="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) - - -def build_regenerate_keys_request( - resource_group_name: str, - namespace_name: str, - topic_name: str, - authorization_rule_name: str, - subscription_id: str, - *, - json: Optional[_models.RegenerateAccessKeyParameters] = None, - content: Any = 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-01-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}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/regenerateKeys") # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - "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, - json=json, - content=content, - **kwargs - ) - - -def build_list_by_namespace_request( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - *, - skip: Optional[int] = None, - top: Optional[int] = 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-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics") # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "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') - if skip is not None: - _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', maximum=1000, minimum=0) - if top is not None: - _params['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) - - # 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, - namespace_name: str, - topic_name: str, - subscription_id: str, - *, - json: Optional[_models.SBTopic] = None, - content: Any = 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-01-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}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}") # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "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="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) - - -def build_delete_request( - resource_group_name: str, - namespace_name: str, - topic_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-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}") # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "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="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) - - -def build_get_request( - resource_group_name: str, - namespace_name: str, - topic_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-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}") # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), - "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 TopicsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.servicebus.v2022_01_01_preview.ServiceBusManagementClient`'s - :attr:`topics` 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_authorization_rules( - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - **kwargs: Any - ) -> Iterable[_models.SBAuthorizationRuleListResult]: - """Gets authorization rules for a topic. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param topic_name: The topic name. - :type topic_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2022_01_01_preview.models.SBAuthorizationRuleListResult] - :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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRuleListResult] - - 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_authorization_rules_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - topic_name=topic_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_authorization_rules.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - else: - - request = build_list_authorization_rules_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - topic_name=topic_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_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("SBAuthorizationRuleListResult", 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( # 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - - return ItemPaged( - get_next, extract_data - ) - list_authorization_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules"} # type: ignore - - @distributed_trace - def create_or_update_authorization_rule( - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - authorization_rule_name: str, - parameters: _models.SBAuthorizationRule, - **kwargs: Any - ) -> _models.SBAuthorizationRule: - """Creates an authorization rule for the specified topic. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param topic_name: The topic name. - :type topic_name: str - :param authorization_rule_name: The authorization rule name. - :type authorization_rule_name: str - :param parameters: The shared access authorization rule. - :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBAuthorizationRule - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBAuthorizationRule - :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-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] - - _json = self._serialize.body(parameters, 'SBAuthorizationRule') - - request = build_create_or_update_authorization_rule_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - topic_name=topic_name, - authorization_rule_name=authorization_rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - template_url=self.create_or_update_authorization_rule.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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create_or_update_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}"} # type: ignore - - - @distributed_trace - def get_authorization_rule( - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - authorization_rule_name: str, - **kwargs: Any - ) -> _models.SBAuthorizationRule: - """Returns the specified authorization rule. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param topic_name: The topic name. - :type topic_name: str - :param authorization_rule_name: The authorization rule name. - :type authorization_rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBAuthorizationRule - :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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] - - - request = build_get_authorization_rule_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - topic_name=topic_name, - authorization_rule_name=authorization_rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get_authorization_rule.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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}"} # type: ignore - - - @distributed_trace - def delete_authorization_rule( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - authorization_rule_name: str, - **kwargs: Any - ) -> None: - """Deletes a topic authorization rule. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param topic_name: The topic name. - :type topic_name: str - :param authorization_rule_name: The authorization rule name. - :type authorization_rule_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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - - - request = build_delete_authorization_rule_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - topic_name=topic_name, - authorization_rule_name=authorization_rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.delete_authorization_rule.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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}"} # type: ignore - - - @distributed_trace - def list_keys( - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - authorization_rule_name: str, - **kwargs: Any - ) -> _models.AccessKeys: - """Gets the primary and secondary connection strings for the topic. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param topic_name: The topic name. - :type topic_name: str - :param authorization_rule_name: The authorization rule name. - :type authorization_rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.AccessKeys - :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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] - - - request = build_list_keys_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - topic_name=topic_name, - authorization_rule_name=authorization_rule_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 - - 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('AccessKeys', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/ListKeys"} # type: ignore - - - @distributed_trace - def regenerate_keys( - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - authorization_rule_name: str, - parameters: _models.RegenerateAccessKeyParameters, - **kwargs: Any - ) -> _models.AccessKeys: - """Regenerates primary or secondary connection strings for the topic. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param topic_name: The topic name. - :type topic_name: str - :param authorization_rule_name: The authorization rule name. - :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate the authorization rule. - :type parameters: - ~azure.mgmt.servicebus.v2022_01_01_preview.models.RegenerateAccessKeyParameters - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.AccessKeys - :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-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] - - _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') - - request = build_regenerate_keys_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - topic_name=topic_name, - authorization_rule_name=authorization_rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - template_url=self.regenerate_keys.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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('AccessKeys', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - regenerate_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/regenerateKeys"} # type: ignore - - - @distributed_trace - def list_by_namespace( - self, - resource_group_name: str, - namespace_name: str, - skip: Optional[int] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable[_models.SBTopicListResult]: - """Gets all the topics in a namespace. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param skip: Skip is only used if a previous operation returned a partial result. If a previous - response contains a nextLink element, the value of the nextLink element will include a skip - parameter that specifies a starting point to use for subsequent calls. Default value is None. - :type skip: int - :param top: May be used to limit the number of results to the most recent N usageDetails. - Default value is None. - :type top: int - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBTopicListResult or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2022_01_01_preview.models.SBTopicListResult] - :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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBTopicListResult] - - 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_namespace_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - skip=skip, - top=top, - template_url=self.list_by_namespace.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - else: - - request = build_list_by_namespace_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - skip=skip, - top=top, - template_url=next_link, - headers=_headers, - params=_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("SBTopicListResult", 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( # 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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - - return ItemPaged( - get_next, extract_data - ) - list_by_namespace.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics"} # type: ignore - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - parameters: _models.SBTopic, - **kwargs: Any - ) -> _models.SBTopic: - """Creates a topic in the specified namespace. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param topic_name: The topic name. - :type topic_name: str - :param parameters: Parameters supplied to create a topic resource. - :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBTopic - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBTopic, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBTopic - :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-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBTopic] - - _json = self._serialize.body(parameters, 'SBTopic') - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - topic_name=topic_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - 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]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('SBTopic', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}"} # type: ignore - - - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - **kwargs: Any - ) -> None: - """Deletes a topic from the specified namespace and resource group. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param topic_name: The topic name. - :type topic_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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - - - request = build_delete_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - topic_name=topic_name, - subscription_id=self._config.subscription_id, - 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.ErrorResponse, 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.ServiceBus/namespaces/{namespaceName}/topics/{topicName}"} # type: ignore - - - @distributed_trace - def get( - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - **kwargs: Any - ) -> _models.SBTopic: - """Returns a description for the specified topic. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param topic_name: The topic name. - :type topic_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBTopic, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBTopic - :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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBTopic] - - - request = build_get_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - topic_name=topic_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.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('SBTopic', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}"} # type: ignore - diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/__init__.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/__init__.py similarity index 86% rename from sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/__init__.py rename to sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/__init__.py index 221541a00fb6e..2e171d69863bf 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/__init__.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/__init__.py @@ -13,11 +13,14 @@ try: from ._patch import __all__ as _patch_all - from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import + from ._patch import * # pylint: disable=unused-wildcard-import except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['ServiceBusManagementClient'] + +__all__ = [ + "ServiceBusManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/_configuration.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/_configuration.py similarity index 62% rename from sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/_configuration.py rename to sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/_configuration.py index 783200eb0f9cc..b212f444418da 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/_configuration.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from ._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential @@ -25,24 +31,19 @@ class ServiceBusManagementClientConfiguration(Configuration): # pylint: disable 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: Subscription credentials that uniquely identify a Microsoft Azure - subscription. The subscription ID forms part of the URI for every service call. + subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2022-01-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(ServiceBusManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str + api_version: Literal["2022-01-01-preview"] = kwargs.pop("api_version", "2022-01-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -52,23 +53,21 @@ def __init__( 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-servicebus/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-servicebus/{}".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') + 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.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/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/_metadata.json b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/_metadata.json similarity index 75% rename from sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/_metadata.json rename to sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/_metadata.json index b470bf08107e5..a455f498b9db8 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/_metadata.json +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_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\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ServiceBusManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"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\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ServiceBusManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"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\": [\"ServiceBusManagementClientConfiguration\"], \".._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\": [\"ServiceBusManagementClientConfiguration\"], \"..._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": "Subscription credentials that uniquely identify a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.", + "signature": "subscription_id: str,", + "description": "Subscription credentials that uniquely identify a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. 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": "Subscription credentials that uniquely identify a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.", + "description": "Subscription credentials that uniquely identify a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. Required.", "docstring_type": "str", "required": true } @@ -48,19 +48,19 @@ "service_client_specific": { "sync": { "api_version": { - "signature": "api_version=None, # type: Optional[str]", + "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=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false }, "profile": { - "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "signature": "profile: KnownProfiles=KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", "required": false @@ -108,4 +108,4 @@ "rules": "RulesOperations", "subscriptions": "SubscriptionsOperations" } -} \ No newline at end of file +} diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/models/_patch.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/_patch.py similarity index 99% rename from sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/models/_patch.py rename to sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/_patch.py index 0ad201a8c586e..f7dd32510333d 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/models/_patch.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/_service_bus_management_client.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/_service_bus_management_client.py similarity index 66% rename from sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/_service_bus_management_client.py rename to sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/_service_bus_management_client.py index fa1bf25ce31ad..859ac1f455d15 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/_service_bus_management_client.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/_service_bus_management_client.py @@ -9,51 +9,62 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from . import models +from . import models as _models +from .._serialization import Deserializer, Serializer from ._configuration import ServiceBusManagementClientConfiguration -from .operations import DisasterRecoveryConfigsOperations, MigrationConfigsOperations, NamespacesOperations, Operations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, QueuesOperations, RulesOperations, SubscriptionsOperations, TopicsOperations +from .operations import ( + DisasterRecoveryConfigsOperations, + MigrationConfigsOperations, + NamespacesOperations, + Operations, + PrivateEndpointConnectionsOperations, + PrivateLinkResourcesOperations, + QueuesOperations, + RulesOperations, + SubscriptionsOperations, + TopicsOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class ServiceBusManagementClient: # pylint: disable=too-many-instance-attributes + +class ServiceBusManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Azure Service Bus client for managing Namespace. :ivar namespaces: NamespacesOperations operations - :vartype namespaces: azure.mgmt.servicebus.v2022_01_01_preview.operations.NamespacesOperations + :vartype namespaces: azure.mgmt.servicebus.v2022_01_10_preview.operations.NamespacesOperations :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations :vartype private_endpoint_connections: - azure.mgmt.servicebus.v2022_01_01_preview.operations.PrivateEndpointConnectionsOperations + azure.mgmt.servicebus.v2022_01_10_preview.operations.PrivateEndpointConnectionsOperations :ivar private_link_resources: PrivateLinkResourcesOperations operations :vartype private_link_resources: - azure.mgmt.servicebus.v2022_01_01_preview.operations.PrivateLinkResourcesOperations + azure.mgmt.servicebus.v2022_01_10_preview.operations.PrivateLinkResourcesOperations :ivar operations: Operations operations - :vartype operations: azure.mgmt.servicebus.v2022_01_01_preview.operations.Operations + :vartype operations: azure.mgmt.servicebus.v2022_01_10_preview.operations.Operations :ivar disaster_recovery_configs: DisasterRecoveryConfigsOperations operations :vartype disaster_recovery_configs: - azure.mgmt.servicebus.v2022_01_01_preview.operations.DisasterRecoveryConfigsOperations + azure.mgmt.servicebus.v2022_01_10_preview.operations.DisasterRecoveryConfigsOperations :ivar migration_configs: MigrationConfigsOperations operations :vartype migration_configs: - azure.mgmt.servicebus.v2022_01_01_preview.operations.MigrationConfigsOperations + azure.mgmt.servicebus.v2022_01_10_preview.operations.MigrationConfigsOperations :ivar queues: QueuesOperations operations - :vartype queues: azure.mgmt.servicebus.v2022_01_01_preview.operations.QueuesOperations + :vartype queues: azure.mgmt.servicebus.v2022_01_10_preview.operations.QueuesOperations :ivar topics: TopicsOperations operations - :vartype topics: azure.mgmt.servicebus.v2022_01_01_preview.operations.TopicsOperations + :vartype topics: azure.mgmt.servicebus.v2022_01_10_preview.operations.TopicsOperations :ivar rules: RulesOperations operations - :vartype rules: azure.mgmt.servicebus.v2022_01_01_preview.operations.RulesOperations + :vartype rules: azure.mgmt.servicebus.v2022_01_10_preview.operations.RulesOperations :ivar subscriptions: SubscriptionsOperations operations :vartype subscriptions: - azure.mgmt.servicebus.v2022_01_01_preview.operations.SubscriptionsOperations - :param credential: Credential needed for the client to connect to Azure. + azure.mgmt.servicebus.v2022_01_10_preview.operations.SubscriptionsOperations + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: Subscription credentials that uniquely identify a Microsoft Azure - subscription. The subscription ID forms part of the URI for every service call. + subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -71,50 +82,35 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = ServiceBusManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = ServiceBusManagementClientConfiguration( + 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)} + 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.namespaces = NamespacesOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.namespaces = NamespacesOperations(self._client, self._config, self._serialize, self._deserialize) self.private_endpoint_connections = PrivateEndpointConnectionsOperations( self._client, self._config, self._serialize, self._deserialize ) self.private_link_resources = PrivateLinkResourcesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize - ) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) self.disaster_recovery_configs = DisasterRecoveryConfigsOperations( self._client, self._config, self._serialize, self._deserialize ) self.migration_configs = MigrationConfigsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.queues = QueuesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.topics = TopicsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.rules = RulesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.subscriptions = SubscriptionsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - + self.queues = QueuesOperations(self._client, self._config, self._serialize, self._deserialize) + self.topics = TopicsOperations(self._client, self._config, self._serialize, self._deserialize) + self.rules = RulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.subscriptions = SubscriptionsOperations(self._client, self._config, self._serialize, self._deserialize) - def _send_request( - self, - request: 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 @@ -123,7 +119,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 @@ -136,15 +132,12 @@ def _send_request( request_copy.url = self._client.format_url(request_copy.url) return self._client.send_request(request_copy, **kwargs) - def close(self): - # type: () -> None + def close(self) -> None: self._client.close() - def __enter__(self): - # type: () -> ServiceBusManagementClient + def __enter__(self) -> "ServiceBusManagementClient": self._client.__enter__() return self - def __exit__(self, *exc_details): - # type: (Any) -> None + def __exit__(self, *exc_details) -> None: self._client.__exit__(*exc_details) diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/_vendor.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/_vendor.py similarity index 89% rename from sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/_vendor.py rename to sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/_vendor.py index 138f663c53a4e..9aad73fc743e7 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/_vendor.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_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/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/_version.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/_version.py similarity index 95% rename from sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/_version.py rename to sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/_version.py index 920456322fa12..e5754a47ce68f 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/_version.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "8.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/__init__.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/aio/__init__.py similarity index 85% rename from sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/__init__.py rename to sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/aio/__init__.py index e7dd87df1f939..530b8638dfd32 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/__init__.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/aio/__init__.py @@ -10,11 +10,14 @@ try: from ._patch import __all__ as _patch_all - from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import + from ._patch import * # pylint: disable=unused-wildcard-import except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['ServiceBusManagementClient'] + +__all__ = [ + "ServiceBusManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/_configuration.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/aio/_configuration.py similarity index 62% rename from sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/_configuration.py rename to sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/aio/_configuration.py index 3dab941141f1c..0ba04e765063a 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/_configuration.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from .._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential @@ -25,24 +31,19 @@ class ServiceBusManagementClientConfiguration(Configuration): # pylint: disable 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: Subscription credentials that uniquely identify a Microsoft Azure - subscription. The subscription ID forms part of the URI for every service call. + subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2022-01-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(ServiceBusManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str + api_version: Literal["2022-01-01-preview"] = kwargs.pop("api_version", "2022-01-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -52,22 +53,21 @@ def __init__( 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-servicebus/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-servicebus/{}".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/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/operations/_patch.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/aio/_patch.py similarity index 99% rename from sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/operations/_patch.py rename to sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/aio/_patch.py index 0ad201a8c586e..f7dd32510333d 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/operations/_patch.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/aio/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/_service_bus_management_client.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/aio/_service_bus_management_client.py similarity index 69% rename from sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/_service_bus_management_client.py rename to sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/aio/_service_bus_management_client.py index 13c1abe32866b..d2c8c396a4433 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/_service_bus_management_client.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/aio/_service_bus_management_client.py @@ -9,52 +9,63 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from .. import models +from .. import models as _models +from ..._serialization import Deserializer, Serializer from ._configuration import ServiceBusManagementClientConfiguration -from .operations import DisasterRecoveryConfigsOperations, MigrationConfigsOperations, NamespacesOperations, Operations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, QueuesOperations, RulesOperations, SubscriptionsOperations, TopicsOperations +from .operations import ( + DisasterRecoveryConfigsOperations, + MigrationConfigsOperations, + NamespacesOperations, + Operations, + PrivateEndpointConnectionsOperations, + PrivateLinkResourcesOperations, + QueuesOperations, + RulesOperations, + SubscriptionsOperations, + TopicsOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class ServiceBusManagementClient: # pylint: disable=too-many-instance-attributes + +class ServiceBusManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Azure Service Bus client for managing Namespace. :ivar namespaces: NamespacesOperations operations :vartype namespaces: - azure.mgmt.servicebus.v2022_01_01_preview.aio.operations.NamespacesOperations + azure.mgmt.servicebus.v2022_01_10_preview.aio.operations.NamespacesOperations :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations :vartype private_endpoint_connections: - azure.mgmt.servicebus.v2022_01_01_preview.aio.operations.PrivateEndpointConnectionsOperations + azure.mgmt.servicebus.v2022_01_10_preview.aio.operations.PrivateEndpointConnectionsOperations :ivar private_link_resources: PrivateLinkResourcesOperations operations :vartype private_link_resources: - azure.mgmt.servicebus.v2022_01_01_preview.aio.operations.PrivateLinkResourcesOperations + azure.mgmt.servicebus.v2022_01_10_preview.aio.operations.PrivateLinkResourcesOperations :ivar operations: Operations operations - :vartype operations: azure.mgmt.servicebus.v2022_01_01_preview.aio.operations.Operations + :vartype operations: azure.mgmt.servicebus.v2022_01_10_preview.aio.operations.Operations :ivar disaster_recovery_configs: DisasterRecoveryConfigsOperations operations :vartype disaster_recovery_configs: - azure.mgmt.servicebus.v2022_01_01_preview.aio.operations.DisasterRecoveryConfigsOperations + azure.mgmt.servicebus.v2022_01_10_preview.aio.operations.DisasterRecoveryConfigsOperations :ivar migration_configs: MigrationConfigsOperations operations :vartype migration_configs: - azure.mgmt.servicebus.v2022_01_01_preview.aio.operations.MigrationConfigsOperations + azure.mgmt.servicebus.v2022_01_10_preview.aio.operations.MigrationConfigsOperations :ivar queues: QueuesOperations operations - :vartype queues: azure.mgmt.servicebus.v2022_01_01_preview.aio.operations.QueuesOperations + :vartype queues: azure.mgmt.servicebus.v2022_01_10_preview.aio.operations.QueuesOperations :ivar topics: TopicsOperations operations - :vartype topics: azure.mgmt.servicebus.v2022_01_01_preview.aio.operations.TopicsOperations + :vartype topics: azure.mgmt.servicebus.v2022_01_10_preview.aio.operations.TopicsOperations :ivar rules: RulesOperations operations - :vartype rules: azure.mgmt.servicebus.v2022_01_01_preview.aio.operations.RulesOperations + :vartype rules: azure.mgmt.servicebus.v2022_01_10_preview.aio.operations.RulesOperations :ivar subscriptions: SubscriptionsOperations operations :vartype subscriptions: - azure.mgmt.servicebus.v2022_01_01_preview.aio.operations.SubscriptionsOperations - :param credential: Credential needed for the client to connect to Azure. + azure.mgmt.servicebus.v2022_01_10_preview.aio.operations.SubscriptionsOperations + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: Subscription credentials that uniquely identify a Microsoft Azure - subscription. The subscription ID forms part of the URI for every service call. + subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -72,50 +83,35 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = ServiceBusManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = ServiceBusManagementClientConfiguration( + 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)} + 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.namespaces = NamespacesOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.namespaces = NamespacesOperations(self._client, self._config, self._serialize, self._deserialize) self.private_endpoint_connections = PrivateEndpointConnectionsOperations( self._client, self._config, self._serialize, self._deserialize ) self.private_link_resources = PrivateLinkResourcesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize - ) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) self.disaster_recovery_configs = DisasterRecoveryConfigsOperations( self._client, self._config, self._serialize, self._deserialize ) self.migration_configs = MigrationConfigsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.queues = QueuesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.topics = TopicsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.rules = RulesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.subscriptions = SubscriptionsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - + self.queues = QueuesOperations(self._client, self._config, self._serialize, self._deserialize) + self.topics = TopicsOperations(self._client, self._config, self._serialize, self._deserialize) + self.rules = RulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.subscriptions = SubscriptionsOperations(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 @@ -124,7 +120,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/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/operations/__init__.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/aio/operations/__init__.py similarity index 76% rename from sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/operations/__init__.py rename to sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/aio/operations/__init__.py index 5559ccd3746c6..e5431803c533c 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/operations/__init__.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/aio/operations/__init__.py @@ -18,19 +18,20 @@ from ._subscriptions_operations import SubscriptionsOperations from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'NamespacesOperations', - 'PrivateEndpointConnectionsOperations', - 'PrivateLinkResourcesOperations', - 'Operations', - 'DisasterRecoveryConfigsOperations', - 'MigrationConfigsOperations', - 'QueuesOperations', - 'TopicsOperations', - 'RulesOperations', - 'SubscriptionsOperations', + "NamespacesOperations", + "PrivateEndpointConnectionsOperations", + "PrivateLinkResourcesOperations", + "Operations", + "DisasterRecoveryConfigsOperations", + "MigrationConfigsOperations", + "QueuesOperations", + "TopicsOperations", + "RulesOperations", + "SubscriptionsOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/aio/operations/_disaster_recovery_configs_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/aio/operations/_disaster_recovery_configs_operations.py new file mode 100644 index 0000000000000..3a027f9bfb5ea --- /dev/null +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/aio/operations/_disaster_recovery_configs_operations.py @@ -0,0 +1,1046 @@ +# 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. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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._disaster_recovery_configs_operations import ( + build_break_pairing_request, + build_check_name_availability_request, + build_create_or_update_request, + build_delete_request, + build_fail_over_request, + build_get_authorization_rule_request, + build_get_request, + build_list_authorization_rules_request, + build_list_keys_request, + build_list_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class DisasterRecoveryConfigsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.servicebus.v2022_01_10_preview.aio.ServiceBusManagementClient`'s + :attr:`disaster_recovery_configs` 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, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ArmDisasterRecovery"]: + """Gets all Alias(Disaster Recovery configurations). + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ArmDisasterRecovery or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2022_01_10_preview.models.ArmDisasterRecovery] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.ArmDisasterRecoveryListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + namespace_name=namespace_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) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ArmDisasterRecoveryListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs" + } + + @overload + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + alias: str, + parameters: _models.ArmDisasterRecovery, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> Optional[_models.ArmDisasterRecovery]: + """Creates or updates a new Alias(Disaster Recovery configuration). + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: str + :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). + Required. + :type parameters: ~azure.mgmt.servicebus.v2022_01_10_preview.models.ArmDisasterRecovery + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ArmDisasterRecovery or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.ArmDisasterRecovery or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + alias: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> Optional[_models.ArmDisasterRecovery]: + """Creates or updates a new Alias(Disaster Recovery configuration). + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: str + :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). + Required. + :type 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: ArmDisasterRecovery or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.ArmDisasterRecovery or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + alias: str, + parameters: Union[_models.ArmDisasterRecovery, IO], + **kwargs: Any + ) -> Optional[_models.ArmDisasterRecovery]: + """Creates or updates a new Alias(Disaster Recovery configuration). + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: str + :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). Is + either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2022_01_10_preview.models.ArmDisasterRecovery 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: ArmDisasterRecovery or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.ArmDisasterRecovery or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + 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: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.ArmDisasterRecovery]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ArmDisasterRecovery") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + alias=alias, + subscription_id=self._config.subscription_id, + 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) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("ArmDisasterRecovery", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}" + } + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, namespace_name: str, alias: str, **kwargs: Any + ) -> None: + """Deletes an Alias(Disaster Recovery configuration). + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: 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, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + alias=alias, + subscription_id=self._config.subscription_id, + 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) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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.ErrorResponse, 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.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}" + } + + @distributed_trace_async + async def get( + self, resource_group_name: str, namespace_name: str, alias: str, **kwargs: Any + ) -> _models.ArmDisasterRecovery: + """Retrieves Alias(Disaster Recovery configuration) for primary or secondary namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ArmDisasterRecovery or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.ArmDisasterRecovery + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.ArmDisasterRecovery] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + alias=alias, + 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) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ArmDisasterRecovery", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}" + } + + @distributed_trace_async + async def break_pairing( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, namespace_name: str, alias: str, **kwargs: Any + ) -> None: + """This operation disables the Disaster Recovery and stops replicating changes from primary to + secondary namespaces. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: 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, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_break_pairing_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + alias=alias, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.break_pairing.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + break_pairing.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/breakPairing" + } + + @overload + async def fail_over( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + namespace_name: str, + alias: str, + parameters: Optional[_models.FailoverProperties] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Invokes GEO DR failover and reconfigure the alias to point to the secondary namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: str + :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). + Default value is None. + :type parameters: ~azure.mgmt.servicebus.v2022_01_10_preview.models.FailoverProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default 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: + """ + + @overload + async def fail_over( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + namespace_name: str, + alias: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Invokes GEO DR failover and reconfigure the alias to point to the secondary namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: str + :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). + Default value is None. + :type 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: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def fail_over( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + namespace_name: str, + alias: str, + parameters: Optional[Union[_models.FailoverProperties, IO]] = None, + **kwargs: Any + ) -> None: + """Invokes GEO DR failover and reconfigure the alias to point to the secondary namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: str + :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). Is + either a model type or a IO type. Default value is None. + :type parameters: ~azure.mgmt.servicebus.v2022_01_10_preview.models.FailoverProperties 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: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + 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: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + if parameters is not None: + _json = self._serialize.body(parameters, "FailoverProperties") + else: + _json = None + + request = build_fail_over_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + alias=alias, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.fail_over.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + fail_over.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/failover" + } + + @distributed_trace + def list_authorization_rules( + self, resource_group_name: str, namespace_name: str, alias: str, **kwargs: Any + ) -> AsyncIterable["_models.SBAuthorizationRule"]: + """Gets the authorization rules for a namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either SBAuthorizationRule or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2022_01_10_preview.models.SBAuthorizationRule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.SBAuthorizationRuleListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_authorization_rules_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + alias=alias, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_authorization_rules.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("SBAuthorizationRuleListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_authorization_rules.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules" + } + + @distributed_trace_async + async def get_authorization_rule( + self, resource_group_name: str, namespace_name: str, alias: str, authorization_rule_name: str, **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Gets an authorization rule for a namespace by rule name. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBAuthorizationRule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.SBAuthorizationRule] = kwargs.pop("cls", None) + + request = build_get_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + alias=alias, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_authorization_rule.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SBAuthorizationRule", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules/{authorizationRuleName}" + } + + @distributed_trace_async + async def list_keys( + self, resource_group_name: str, namespace_name: str, alias: str, authorization_rule_name: str, **kwargs: Any + ) -> _models.AccessKeys: + """Gets the primary and secondary connection strings for the namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AccessKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.AccessKeys] = kwargs.pop("cls", None) + + request = build_list_keys_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + alias=alias, + authorization_rule_name=authorization_rule_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) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("AccessKeys", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules/{authorizationRuleName}/listKeys" + } + + @overload + async def check_name_availability( + self, + resource_group_name: str, + namespace_name: str, + parameters: _models.CheckNameAvailability, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters to check availability of the given namespace name. Required. + :type parameters: ~azure.mgmt.servicebus.v2022_01_10_preview.models.CheckNameAvailability + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckNameAvailabilityResult or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters to check availability of the given namespace name. Required. + :type 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: CheckNameAvailabilityResult or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_name_availability( + self, + resource_group_name: str, + namespace_name: str, + parameters: Union[_models.CheckNameAvailability, IO], + **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters to check availability of the given namespace name. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2022_01_10_preview.models.CheckNameAvailability 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: CheckNameAvailabilityResult or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + 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: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CheckNameAvailabilityResult] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "CheckNameAvailability") + + request = build_check_name_availability_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + 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) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + check_name_availability.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/CheckNameAvailability" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/aio/operations/_migration_configs_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/aio/operations/_migration_configs_operations.py new file mode 100644 index 0000000000000..0d8058149f5b5 --- /dev/null +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/aio/operations/_migration_configs_operations.py @@ -0,0 +1,690 @@ +# 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. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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._migration_configs_operations import ( + build_complete_migration_request, + build_create_and_start_migration_request, + build_delete_request, + build_get_request, + build_list_request, + build_revert_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class MigrationConfigsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.servicebus.v2022_01_10_preview.aio.ServiceBusManagementClient`'s + :attr:`migration_configs` 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, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> AsyncIterable["_models.MigrationConfigProperties"]: + """Gets all migrationConfigurations. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either MigrationConfigProperties or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2022_01_10_preview.models.MigrationConfigProperties] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.MigrationConfigListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + namespace_name=namespace_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) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("MigrationConfigListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations" + } + + async def _create_and_start_migration_initial( + self, + resource_group_name: str, + namespace_name: str, + config_name: Union[str, _models.MigrationConfigurationName], + parameters: Union[_models.MigrationConfigProperties, IO], + **kwargs: Any + ) -> Optional[_models.MigrationConfigProperties]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + 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: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.MigrationConfigProperties]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "MigrationConfigProperties") + + request = build_create_and_start_migration_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + config_name=config_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_and_start_migration_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("MigrationConfigProperties", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_and_start_migration_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}" + } + + @overload + async def begin_create_and_start_migration( + self, + resource_group_name: str, + namespace_name: str, + config_name: Union[str, _models.MigrationConfigurationName], + parameters: _models.MigrationConfigProperties, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.MigrationConfigProperties]: + """Creates Migration configuration and starts migration of entities from Standard to Premium + namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param config_name: The configuration name. Should always be "$default". "$default" Required. + :type config_name: str or + ~azure.mgmt.servicebus.v2022_01_10_preview.models.MigrationConfigurationName + :param parameters: Parameters required to create Migration Configuration. Required. + :type parameters: ~azure.mgmt.servicebus.v2022_01_10_preview.models.MigrationConfigProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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 MigrationConfigProperties or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.servicebus.v2022_01_10_preview.models.MigrationConfigProperties] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_and_start_migration( + self, + resource_group_name: str, + namespace_name: str, + config_name: Union[str, _models.MigrationConfigurationName], + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.MigrationConfigProperties]: + """Creates Migration configuration and starts migration of entities from Standard to Premium + namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param config_name: The configuration name. Should always be "$default". "$default" Required. + :type config_name: str or + ~azure.mgmt.servicebus.v2022_01_10_preview.models.MigrationConfigurationName + :param parameters: Parameters required to create Migration Configuration. Required. + :type 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 + :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 MigrationConfigProperties or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.servicebus.v2022_01_10_preview.models.MigrationConfigProperties] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_and_start_migration( + self, + resource_group_name: str, + namespace_name: str, + config_name: Union[str, _models.MigrationConfigurationName], + parameters: Union[_models.MigrationConfigProperties, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.MigrationConfigProperties]: + """Creates Migration configuration and starts migration of entities from Standard to Premium + namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param config_name: The configuration name. Should always be "$default". "$default" Required. + :type config_name: str or + ~azure.mgmt.servicebus.v2022_01_10_preview.models.MigrationConfigurationName + :param parameters: Parameters required to create Migration Configuration. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2022_01_10_preview.models.MigrationConfigProperties + 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 MigrationConfigProperties or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.servicebus.v2022_01_10_preview.models.MigrationConfigProperties] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.MigrationConfigProperties] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_and_start_migration_initial( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + config_name=config_name, + parameters=parameters, + 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("MigrationConfigProperties", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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) # type: ignore + + begin_create_and_start_migration.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}" + } + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + namespace_name: str, + config_name: Union[str, _models.MigrationConfigurationName], + **kwargs: Any + ) -> None: + """Deletes a MigrationConfiguration. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param config_name: The configuration name. Should always be "$default". "$default" Required. + :type config_name: str or + ~azure.mgmt.servicebus.v2022_01_10_preview.models.MigrationConfigurationName + :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, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + config_name=config_name, + subscription_id=self._config.subscription_id, + 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) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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.ErrorResponse, 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.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}" + } + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + namespace_name: str, + config_name: Union[str, _models.MigrationConfigurationName], + **kwargs: Any + ) -> _models.MigrationConfigProperties: + """Retrieves Migration Config. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param config_name: The configuration name. Should always be "$default". "$default" Required. + :type config_name: str or + ~azure.mgmt.servicebus.v2022_01_10_preview.models.MigrationConfigurationName + :keyword callable cls: A custom type or function that will be passed the direct response + :return: MigrationConfigProperties or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.MigrationConfigProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.MigrationConfigProperties] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + config_name=config_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) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("MigrationConfigProperties", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}" + } + + @distributed_trace_async + async def complete_migration( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + namespace_name: str, + config_name: Union[str, _models.MigrationConfigurationName], + **kwargs: Any + ) -> None: + """This operation Completes Migration of entities by pointing the connection strings to Premium + namespace and any entities created after the operation will be under Premium Namespace. + CompleteMigration operation will fail when entity migration is in-progress. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param config_name: The configuration name. Should always be "$default". "$default" Required. + :type config_name: str or + ~azure.mgmt.servicebus.v2022_01_10_preview.models.MigrationConfigurationName + :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, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_complete_migration_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + config_name=config_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.complete_migration.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + complete_migration.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/upgrade" + } + + @distributed_trace_async + async def revert( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + namespace_name: str, + config_name: Union[str, _models.MigrationConfigurationName], + **kwargs: Any + ) -> None: + """This operation reverts Migration. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param config_name: The configuration name. Should always be "$default". "$default" Required. + :type config_name: str or + ~azure.mgmt.servicebus.v2022_01_10_preview.models.MigrationConfigurationName + :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, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_revert_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + config_name=config_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.revert.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + revert.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/revert" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/aio/operations/_namespaces_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/aio/operations/_namespaces_operations.py new file mode 100644 index 0000000000000..74c23e420f648 --- /dev/null +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/aio/operations/_namespaces_operations.py @@ -0,0 +1,1808 @@ +# 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. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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._namespaces_operations import ( + build_check_name_availability_request, + build_create_or_update_authorization_rule_request, + build_create_or_update_network_rule_set_request, + build_create_or_update_request, + build_delete_authorization_rule_request, + build_delete_request, + build_get_authorization_rule_request, + build_get_network_rule_set_request, + build_get_request, + build_list_authorization_rules_request, + build_list_by_resource_group_request, + build_list_keys_request, + build_list_network_rule_sets_request, + build_list_request, + build_regenerate_keys_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class NamespacesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.servicebus.v2022_01_10_preview.aio.ServiceBusManagementClient`'s + :attr:`namespaces` 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.SBNamespace"]: + """Gets all the available namespaces within the subscription, irrespective of the resource groups. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either SBNamespace or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2022_01_10_preview.models.SBNamespace] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.SBNamespaceListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + 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) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("SBNamespaceListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/namespaces"} + + @distributed_trace + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.SBNamespace"]: + """Gets the available namespaces within a resource group. + + :param resource_group_name: Name of the Resource group within the Azure subscription. 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 SBNamespace or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2022_01_10_preview.models.SBNamespace] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.SBNamespaceListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + 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) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("SBNamespaceListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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.ErrorResponse, 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.ServiceBus/namespaces" + } + + async def _create_or_update_initial( + self, resource_group_name: str, namespace_name: str, parameters: Union[_models.SBNamespace, IO], **kwargs: Any + ) -> Optional[_models.SBNamespace]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + 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: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.SBNamespace]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBNamespace") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + 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) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("SBNamespace", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("SBNamespace", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}" + } + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + namespace_name: str, + parameters: _models.SBNamespace, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.SBNamespace]: + """Creates or updates a service namespace. Once created, this namespace's resource manifest is + immutable. This operation is idempotent. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to create a namespace resource. Required. + :type parameters: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SBNamespace + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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 SBNamespace or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.servicebus.v2022_01_10_preview.models.SBNamespace] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.SBNamespace]: + """Creates or updates a service namespace. Once created, this namespace's resource manifest is + immutable. This operation is idempotent. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to create a namespace resource. Required. + :type 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 + :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 SBNamespace or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.servicebus.v2022_01_10_preview.models.SBNamespace] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, resource_group_name: str, namespace_name: str, parameters: Union[_models.SBNamespace, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.SBNamespace]: + """Creates or updates a service namespace. Once created, this namespace's resource manifest is + immutable. This operation is idempotent. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to create a namespace resource. Is either a model type + or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SBNamespace 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 SBNamespace or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.servicebus.v2022_01_10_preview.models.SBNamespace] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SBNamespace] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + parameters=parameters, + 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("SBNamespace", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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) # type: ignore + + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + namespace_name=namespace_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) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}" + } + + @distributed_trace_async + async def begin_delete(self, resource_group_name: str, namespace_name: str, **kwargs: Any) -> AsyncLROPoller[None]: + """Deletes an existing namespace. This operation also removes all associated resources under the + namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_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 None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + namespace_name=namespace_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): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}" + } + + @distributed_trace_async + async def get(self, resource_group_name: str, namespace_name: str, **kwargs: Any) -> _models.SBNamespace: + """Gets a description for the specified namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBNamespace or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SBNamespace + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.SBNamespace] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_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) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SBNamespace", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}" + } + + @overload + async def update( + self, + resource_group_name: str, + namespace_name: str, + parameters: _models.SBNamespaceUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> Optional[_models.SBNamespace]: + """Updates a service namespace. Once created, this namespace's resource manifest is immutable. + This operation is idempotent. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to update a namespace resource. Required. + :type parameters: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SBNamespaceUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBNamespace or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SBNamespace or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> Optional[_models.SBNamespace]: + """Updates a service namespace. Once created, this namespace's resource manifest is immutable. + This operation is idempotent. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to update a namespace resource. Required. + :type 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: SBNamespace or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SBNamespace or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + namespace_name: str, + parameters: Union[_models.SBNamespaceUpdateParameters, IO], + **kwargs: Any + ) -> Optional[_models.SBNamespace]: + """Updates a service namespace. Once created, this namespace's resource manifest is immutable. + This operation is idempotent. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to update a namespace resource. Is either a model type + or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SBNamespaceUpdateParameters + 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: SBNamespace or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SBNamespace or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + 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: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.SBNamespace]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBNamespaceUpdateParameters") + + request = build_update_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("SBNamespace", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("SBNamespace", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}" + } + + @overload + async def create_or_update_network_rule_set( + self, + resource_group_name: str, + namespace_name: str, + parameters: _models.NetworkRuleSet, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.NetworkRuleSet: + """Create or update NetworkRuleSet for a Namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: The Namespace IpFilterRule. Required. + :type parameters: ~azure.mgmt.servicebus.v2022_01_10_preview.models.NetworkRuleSet + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: NetworkRuleSet or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.NetworkRuleSet + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_network_rule_set( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.NetworkRuleSet: + """Create or update NetworkRuleSet for a Namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: The Namespace IpFilterRule. Required. + :type 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: NetworkRuleSet or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.NetworkRuleSet + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update_network_rule_set( + self, + resource_group_name: str, + namespace_name: str, + parameters: Union[_models.NetworkRuleSet, IO], + **kwargs: Any + ) -> _models.NetworkRuleSet: + """Create or update NetworkRuleSet for a Namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: The Namespace IpFilterRule. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2022_01_10_preview.models.NetworkRuleSet 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: NetworkRuleSet or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.NetworkRuleSet + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + 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: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.NetworkRuleSet] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "NetworkRuleSet") + + request = build_create_or_update_network_rule_set_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update_network_rule_set.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("NetworkRuleSet", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update_network_rule_set.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default" + } + + @distributed_trace_async + async def get_network_rule_set( + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> _models.NetworkRuleSet: + """Gets NetworkRuleSet for a Namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: NetworkRuleSet or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.NetworkRuleSet + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.NetworkRuleSet] = kwargs.pop("cls", None) + + request = build_get_network_rule_set_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_network_rule_set.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("NetworkRuleSet", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_network_rule_set.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default" + } + + @distributed_trace + def list_network_rule_sets( + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> AsyncIterable["_models.NetworkRuleSet"]: + """Gets list of NetworkRuleSet for a Namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either NetworkRuleSet or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2022_01_10_preview.models.NetworkRuleSet] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.NetworkRuleSetListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_network_rule_sets_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_network_rule_sets.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("NetworkRuleSetListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_network_rule_sets.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets" + } + + @distributed_trace + def list_authorization_rules( + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> AsyncIterable["_models.SBAuthorizationRule"]: + """Gets the authorization rules for a namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either SBAuthorizationRule or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2022_01_10_preview.models.SBAuthorizationRule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.SBAuthorizationRuleListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_authorization_rules_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_authorization_rules.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("SBAuthorizationRuleListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_authorization_rules.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules" + } + + @overload + async def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: _models.SBAuthorizationRule, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates or updates an authorization rule for a namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Required. + :type parameters: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SBAuthorizationRule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBAuthorizationRule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates or updates an authorization rule for a namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Required. + :type 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: SBAuthorizationRule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: Union[_models.SBAuthorizationRule, IO], + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates or updates an authorization rule for a namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SBAuthorizationRule 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: SBAuthorizationRule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + 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: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SBAuthorizationRule] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBAuthorizationRule") + + request = build_create_or_update_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update_authorization_rule.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SBAuthorizationRule", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}" + } + + @distributed_trace_async + async def delete_authorization_rule( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, namespace_name: str, authorization_rule_name: str, **kwargs: Any + ) -> None: + """Deletes a namespace authorization rule. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_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, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_authorization_rule.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}" + } + + @distributed_trace_async + async def get_authorization_rule( + self, resource_group_name: str, namespace_name: str, authorization_rule_name: str, **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Gets an authorization rule for a namespace by rule name. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBAuthorizationRule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.SBAuthorizationRule] = kwargs.pop("cls", None) + + request = build_get_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_authorization_rule.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SBAuthorizationRule", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}" + } + + @distributed_trace_async + async def list_keys( + self, resource_group_name: str, namespace_name: str, authorization_rule_name: str, **kwargs: Any + ) -> _models.AccessKeys: + """Gets the primary and secondary connection strings for the namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AccessKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.AccessKeys] = kwargs.pop("cls", None) + + request = build_list_keys_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + authorization_rule_name=authorization_rule_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) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("AccessKeys", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/listKeys" + } + + @overload + async def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: _models.RegenerateAccessKeyParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AccessKeys: + """Regenerates the primary or secondary connection strings for the namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Required. + :type parameters: + ~azure.mgmt.servicebus.v2022_01_10_preview.models.RegenerateAccessKeyParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AccessKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AccessKeys: + """Regenerates the primary or secondary connection strings for the namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Required. + :type 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: AccessKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: Union[_models.RegenerateAccessKeyParameters, IO], + **kwargs: Any + ) -> _models.AccessKeys: + """Regenerates the primary or secondary connection strings for the namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Is either a model + type or a IO type. Required. + :type parameters: + ~azure.mgmt.servicebus.v2022_01_10_preview.models.RegenerateAccessKeyParameters 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: AccessKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + 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: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AccessKeys] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RegenerateAccessKeyParameters") + + request = build_regenerate_keys_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.regenerate_keys.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("AccessKeys", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + regenerate_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/regenerateKeys" + } + + @overload + async def check_name_availability( + self, parameters: _models.CheckNameAvailability, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param parameters: Parameters to check availability of the given namespace name. Required. + :type parameters: ~azure.mgmt.servicebus.v2022_01_10_preview.models.CheckNameAvailability + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckNameAvailabilityResult or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param parameters: Parameters to check availability of the given namespace name. Required. + :type 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: CheckNameAvailabilityResult or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_name_availability( + self, parameters: Union[_models.CheckNameAvailability, IO], **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param parameters: Parameters to check availability of the given namespace name. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2022_01_10_preview.models.CheckNameAvailability 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: CheckNameAvailabilityResult or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + 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: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CheckNameAvailabilityResult] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "CheckNameAvailability") + + 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) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + check_name_availability.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/CheckNameAvailability" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/operations/_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/aio/operations/_operations.py similarity index 61% rename from sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/operations/_operations.py rename to sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/aio/operations/_operations.py index 6691d1b4ee72b..cbb2129ac41ba 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/operations/_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/aio/operations/_operations.py @@ -6,10 +6,19 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse 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, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,16 +29,22 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._operations import build_list_request -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +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.servicebus.v2022_01_01_preview.aio.ServiceBusManagementClient`'s + :class:`~azure.mgmt.servicebus.v2022_01_10_preview.aio.ServiceBusManagementClient`'s :attr:`operations` attribute. """ @@ -42,52 +57,59 @@ def __init__(self, *args, **kwargs) -> None: 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 ServiceBus 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.servicebus.v2022_01_01_preview.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2022_01_10_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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_request( - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -95,16 +117,14 @@ 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) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -115,8 +135,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.ServiceBus/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.ServiceBus/operations"} diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/_patch.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/aio/operations/_patch.py similarity index 99% rename from sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/_patch.py rename to sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/aio/operations/_patch.py index 0ad201a8c586e..f7dd32510333d 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/_patch.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/aio/operations/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/aio/operations/_private_endpoint_connections_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/aio/operations/_private_endpoint_connections_operations.py new file mode 100644 index 0000000000000..39d5199d56f90 --- /dev/null +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/aio/operations/_private_endpoint_connections_operations.py @@ -0,0 +1,509 @@ +# 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. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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._private_endpoint_connections_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +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.servicebus.v2022_01_10_preview.aio.ServiceBusManagementClient`'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 + def list( + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> AsyncIterable["_models.PrivateEndpointConnection"]: + """Gets the available PrivateEndpointConnections within a namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either PrivateEndpointConnection or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2022_01_10_preview.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + namespace_name=namespace_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) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections" + } + + @overload + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + private_endpoint_connection_name: str, + parameters: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Creates or updates PrivateEndpointConnections of service namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param private_endpoint_connection_name: The PrivateEndpointConnection name. Required. + :type private_endpoint_connection_name: str + :param parameters: Parameters supplied to update Status of PrivateEndPoint Connection to + namespace resource. Required. + :type parameters: ~azure.mgmt.servicebus.v2022_01_10_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 + :return: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + private_endpoint_connection_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Creates or updates PrivateEndpointConnections of service namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param private_endpoint_connection_name: The PrivateEndpointConnection name. Required. + :type private_endpoint_connection_name: str + :param parameters: Parameters supplied to update Status of PrivateEndPoint Connection to + namespace resource. Required. + :type 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: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + private_endpoint_connection_name: str, + parameters: Union[_models.PrivateEndpointConnection, IO], + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Creates or updates PrivateEndpointConnections of service namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param private_endpoint_connection_name: The PrivateEndpointConnection name. Required. + :type private_endpoint_connection_name: str + :param parameters: Parameters supplied to update Status of PrivateEndPoint Connection to + namespace resource. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2022_01_10_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 + :return: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + 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: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PrivateEndpointConnection") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + namespace_name=namespace_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.create_or_update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, namespace_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + namespace_name=namespace_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) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}" + } + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, namespace_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes an existing Private Endpoint Connection. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param private_endpoint_connection_name: The PrivateEndpointConnection name. 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 None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + namespace_name=namespace_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): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}" + } + + @distributed_trace_async + async def get( + self, resource_group_name: str, namespace_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Gets a description for the specified Private Endpoint Connection. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param private_endpoint_connection_name: The PrivateEndpointConnection name. 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.servicebus.v2022_01_10_preview.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_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) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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.ErrorResponse, 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.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/operations/_private_link_resources_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/aio/operations/_private_link_resources_operations.py similarity index 63% rename from sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/operations/_private_link_resources_operations.py rename to sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/aio/operations/_private_link_resources_operations.py index 9ae4e692ece3d..580102bafd9b9 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/operations/_private_link_resources_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/aio/operations/_private_link_resources_operations.py @@ -6,9 +6,17 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Optional, TypeVar -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -19,16 +27,22 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._private_link_resources_operations import build_get_request -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +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.servicebus.v2022_01_01_preview.aio.ServiceBusManagementClient`'s + :class:`~azure.mgmt.servicebus.v2022_01_10_preview.aio.ServiceBusManagementClient`'s :attr:`private_link_resources` attribute. """ @@ -41,54 +55,53 @@ def __init__(self, *args, **kwargs) -> None: 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, - namespace_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, **kwargs: Any ) -> _models.PrivateLinkResourcesListResult: """Gets lists of resources that supports Privatelinks. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateLinkResourcesListResult, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.PrivateLinkResourcesListResult - :raises: ~azure.core.exceptions.HttpResponseError + :return: PrivateLinkResourcesListResult or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.PrivateLinkResourcesListResult + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateLinkResourcesListResult] + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.PrivateLinkResourcesListResult] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -96,12 +109,13 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateLinkResourcesListResult', pipeline_response) + deserialized = self._deserialize("PrivateLinkResourcesListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateLinkResources"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateLinkResources" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/aio/operations/_queues_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/aio/operations/_queues_operations.py new file mode 100644 index 0000000000000..38f378fea8e49 --- /dev/null +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/aio/operations/_queues_operations.py @@ -0,0 +1,1104 @@ +# 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. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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._queues_operations import ( + build_create_or_update_authorization_rule_request, + build_create_or_update_request, + build_delete_authorization_rule_request, + build_delete_request, + build_get_authorization_rule_request, + build_get_request, + build_list_authorization_rules_request, + build_list_by_namespace_request, + build_list_keys_request, + build_regenerate_keys_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class QueuesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.servicebus.v2022_01_10_preview.aio.ServiceBusManagementClient`'s + :attr:`queues` 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_authorization_rules( + self, resource_group_name: str, namespace_name: str, queue_name: str, **kwargs: Any + ) -> AsyncIterable["_models.SBAuthorizationRule"]: + """Gets all authorization rules for a queue. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either SBAuthorizationRule or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2022_01_10_preview.models.SBAuthorizationRule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.SBAuthorizationRuleListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_authorization_rules_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_authorization_rules.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("SBAuthorizationRuleListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_authorization_rules.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules" + } + + @overload + async def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: _models.SBAuthorizationRule, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates an authorization rule for a queue. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Required. + :type parameters: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SBAuthorizationRule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBAuthorizationRule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates an authorization rule for a queue. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Required. + :type 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: SBAuthorizationRule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: Union[_models.SBAuthorizationRule, IO], + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates an authorization rule for a queue. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SBAuthorizationRule 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: SBAuthorizationRule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + 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: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SBAuthorizationRule] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBAuthorizationRule") + + request = build_create_or_update_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update_authorization_rule.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SBAuthorizationRule", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}" + } + + @distributed_trace_async + async def delete_authorization_rule( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + **kwargs: Any + ) -> None: + """Deletes a queue authorization rule. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_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, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_authorization_rule.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}" + } + + @distributed_trace_async + async def get_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Gets an authorization rule for a queue by rule name. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBAuthorizationRule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.SBAuthorizationRule] = kwargs.pop("cls", None) + + request = build_get_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_authorization_rule.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SBAuthorizationRule", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}" + } + + @distributed_trace_async + async def list_keys( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + **kwargs: Any + ) -> _models.AccessKeys: + """Primary and secondary connection strings to the queue. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AccessKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.AccessKeys] = kwargs.pop("cls", None) + + request = build_list_keys_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + authorization_rule_name=authorization_rule_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) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("AccessKeys", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/ListKeys" + } + + @overload + async def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: _models.RegenerateAccessKeyParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AccessKeys: + """Regenerates the primary or secondary connection strings to the queue. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Required. + :type parameters: + ~azure.mgmt.servicebus.v2022_01_10_preview.models.RegenerateAccessKeyParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AccessKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AccessKeys: + """Regenerates the primary or secondary connection strings to the queue. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Required. + :type 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: AccessKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: Union[_models.RegenerateAccessKeyParameters, IO], + **kwargs: Any + ) -> _models.AccessKeys: + """Regenerates the primary or secondary connection strings to the queue. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Is either a model + type or a IO type. Required. + :type parameters: + ~azure.mgmt.servicebus.v2022_01_10_preview.models.RegenerateAccessKeyParameters 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: AccessKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + 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: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AccessKeys] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RegenerateAccessKeyParameters") + + request = build_regenerate_keys_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.regenerate_keys.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("AccessKeys", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + regenerate_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/regenerateKeys" + } + + @distributed_trace + def list_by_namespace( + self, + resource_group_name: str, + namespace_name: str, + skip: Optional[int] = None, + top: Optional[int] = None, + **kwargs: Any + ) -> AsyncIterable["_models.SBQueue"]: + """Gets the queues within a namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param skip: Skip is only used if a previous operation returned a partial result. If a previous + response contains a nextLink element, the value of the nextLink element will include a skip + parameter that specifies a starting point to use for subsequent calls. Default value is None. + :type skip: int + :param top: May be used to limit the number of results to the most recent N usageDetails. + Default value is None. + :type top: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either SBQueue or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2022_01_10_preview.models.SBQueue] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.SBQueueListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_namespace_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + skip=skip, + top=top, + api_version=api_version, + template_url=self.list_by_namespace.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("SBQueueListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_namespace.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues" + } + + @overload + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + parameters: _models.SBQueue, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBQueue: + """Creates or updates a Service Bus queue. This operation is idempotent. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param parameters: Parameters supplied to create or update a queue resource. Required. + :type parameters: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SBQueue + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBQueue or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SBQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBQueue: + """Creates or updates a Service Bus queue. This operation is idempotent. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param parameters: Parameters supplied to create or update a queue resource. Required. + :type 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: SBQueue or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SBQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + parameters: Union[_models.SBQueue, IO], + **kwargs: Any + ) -> _models.SBQueue: + """Creates or updates a Service Bus queue. This operation is idempotent. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param parameters: Parameters supplied to create or update a queue resource. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SBQueue 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: SBQueue or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SBQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + 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: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SBQueue] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBQueue") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + subscription_id=self._config.subscription_id, + 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) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SBQueue", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}" + } + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, namespace_name: str, queue_name: str, **kwargs: Any + ) -> None: + """Deletes a queue from the specified namespace in a resource group. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_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, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + subscription_id=self._config.subscription_id, + 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) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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.ErrorResponse, 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.ServiceBus/namespaces/{namespaceName}/queues/{queueName}" + } + + @distributed_trace_async + async def get( + self, resource_group_name: str, namespace_name: str, queue_name: str, **kwargs: Any + ) -> _models.SBQueue: + """Returns a description for the specified queue. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBQueue or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SBQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.SBQueue] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_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) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SBQueue", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/aio/operations/_rules_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/aio/operations/_rules_operations.py new file mode 100644 index 0000000000000..697832ba9551f --- /dev/null +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/aio/operations/_rules_operations.py @@ -0,0 +1,506 @@ +# 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. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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._rules_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_subscriptions_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class RulesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.servicebus.v2022_01_10_preview.aio.ServiceBusManagementClient`'s + :attr:`rules` 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_by_subscriptions( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + skip: Optional[int] = None, + top: Optional[int] = None, + **kwargs: Any + ) -> AsyncIterable["_models.Rule"]: + """List all the rules within given topic-subscription. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param skip: Skip is only used if a previous operation returned a partial result. If a previous + response contains a nextLink element, the value of the nextLink element will include a skip + parameter that specifies a starting point to use for subsequent calls. Default value is None. + :type skip: int + :param top: May be used to limit the number of results to the most recent N usageDetails. + Default value is None. + :type top: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Rule or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2022_01_10_preview.models.Rule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.RuleListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscriptions_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_name=subscription_name, + subscription_id=self._config.subscription_id, + skip=skip, + top=top, + api_version=api_version, + template_url=self.list_by_subscriptions.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("RuleListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_subscriptions.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules" + } + + @overload + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + rule_name: str, + parameters: _models.Rule, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Rule: + """Creates a new rule and updates an existing rule. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param rule_name: The rule name. Required. + :type rule_name: str + :param parameters: Parameters supplied to create a rule. Required. + :type parameters: ~azure.mgmt.servicebus.v2022_01_10_preview.models.Rule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Rule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.Rule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Rule: + """Creates a new rule and updates an existing rule. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param rule_name: The rule name. Required. + :type rule_name: str + :param parameters: Parameters supplied to create a rule. Required. + :type 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: Rule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.Rule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + rule_name: str, + parameters: Union[_models.Rule, IO], + **kwargs: Any + ) -> _models.Rule: + """Creates a new rule and updates an existing rule. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param rule_name: The rule name. Required. + :type rule_name: str + :param parameters: Parameters supplied to create a rule. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.servicebus.v2022_01_10_preview.models.Rule 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: Rule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.Rule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + 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: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Rule] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Rule") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_name=subscription_name, + rule_name=rule_name, + subscription_id=self._config.subscription_id, + 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) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Rule", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}" + } + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + rule_name: str, + **kwargs: Any + ) -> None: + """Deletes an existing rule. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param rule_name: The rule name. Required. + :type rule_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, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_name=subscription_name, + rule_name=rule_name, + subscription_id=self._config.subscription_id, + 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) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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.ErrorResponse, 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.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}" + } + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + rule_name: str, + **kwargs: Any + ) -> _models.Rule: + """Retrieves the description for the specified rule. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param rule_name: The rule name. Required. + :type rule_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Rule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.Rule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.Rule] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_name=subscription_name, + rule_name=rule_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) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Rule", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/aio/operations/_subscriptions_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/aio/operations/_subscriptions_operations.py new file mode 100644 index 0000000000000..b630682f9d30b --- /dev/null +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/aio/operations/_subscriptions_operations.py @@ -0,0 +1,474 @@ +# 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. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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._subscriptions_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_topic_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class SubscriptionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.servicebus.v2022_01_10_preview.aio.ServiceBusManagementClient`'s + :attr:`subscriptions` 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_by_topic( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + skip: Optional[int] = None, + top: Optional[int] = None, + **kwargs: Any + ) -> AsyncIterable["_models.SBSubscription"]: + """List all the subscriptions under a specified topic. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param skip: Skip is only used if a previous operation returned a partial result. If a previous + response contains a nextLink element, the value of the nextLink element will include a skip + parameter that specifies a starting point to use for subsequent calls. Default value is None. + :type skip: int + :param top: May be used to limit the number of results to the most recent N usageDetails. + Default value is None. + :type top: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either SBSubscription or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2022_01_10_preview.models.SBSubscription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.SBSubscriptionListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_topic_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_id=self._config.subscription_id, + skip=skip, + top=top, + api_version=api_version, + template_url=self.list_by_topic.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("SBSubscriptionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_topic.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions" + } + + @overload + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + parameters: _models.SBSubscription, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBSubscription: + """Creates a topic subscription. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param parameters: Parameters supplied to create a subscription resource. Required. + :type parameters: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SBSubscription + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBSubscription or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SBSubscription + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBSubscription: + """Creates a topic subscription. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param parameters: Parameters supplied to create a subscription resource. Required. + :type 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: SBSubscription or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SBSubscription + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + parameters: Union[_models.SBSubscription, IO], + **kwargs: Any + ) -> _models.SBSubscription: + """Creates a topic subscription. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param parameters: Parameters supplied to create a subscription resource. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SBSubscription 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: SBSubscription or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SBSubscription + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + 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: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SBSubscription] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBSubscription") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_name=subscription_name, + subscription_id=self._config.subscription_id, + 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) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SBSubscription", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}" + } + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, namespace_name: str, topic_name: str, subscription_name: str, **kwargs: Any + ) -> None: + """Deletes a subscription from the specified topic. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_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, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_name=subscription_name, + subscription_id=self._config.subscription_id, + 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) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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.ErrorResponse, 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.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}" + } + + @distributed_trace_async + async def get( + self, resource_group_name: str, namespace_name: str, topic_name: str, subscription_name: str, **kwargs: Any + ) -> _models.SBSubscription: + """Returns a subscription description for the specified topic. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBSubscription or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SBSubscription + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.SBSubscription] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_name=subscription_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) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SBSubscription", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/aio/operations/_topics_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/aio/operations/_topics_operations.py new file mode 100644 index 0000000000000..06c6b599aabcd --- /dev/null +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/aio/operations/_topics_operations.py @@ -0,0 +1,1104 @@ +# 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. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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._topics_operations import ( + build_create_or_update_authorization_rule_request, + build_create_or_update_request, + build_delete_authorization_rule_request, + build_delete_request, + build_get_authorization_rule_request, + build_get_request, + build_list_authorization_rules_request, + build_list_by_namespace_request, + build_list_keys_request, + build_regenerate_keys_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class TopicsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.servicebus.v2022_01_10_preview.aio.ServiceBusManagementClient`'s + :attr:`topics` 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_authorization_rules( + self, resource_group_name: str, namespace_name: str, topic_name: str, **kwargs: Any + ) -> AsyncIterable["_models.SBAuthorizationRule"]: + """Gets authorization rules for a topic. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either SBAuthorizationRule or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2022_01_10_preview.models.SBAuthorizationRule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.SBAuthorizationRuleListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_authorization_rules_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_authorization_rules.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("SBAuthorizationRuleListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_authorization_rules.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules" + } + + @overload + async def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: _models.SBAuthorizationRule, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates an authorization rule for the specified topic. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Required. + :type parameters: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SBAuthorizationRule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBAuthorizationRule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates an authorization rule for the specified topic. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Required. + :type 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: SBAuthorizationRule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: Union[_models.SBAuthorizationRule, IO], + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates an authorization rule for the specified topic. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SBAuthorizationRule 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: SBAuthorizationRule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + 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: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SBAuthorizationRule] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBAuthorizationRule") + + request = build_create_or_update_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update_authorization_rule.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SBAuthorizationRule", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}" + } + + @distributed_trace_async + async def get_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Returns the specified authorization rule. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBAuthorizationRule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.SBAuthorizationRule] = kwargs.pop("cls", None) + + request = build_get_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_authorization_rule.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SBAuthorizationRule", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}" + } + + @distributed_trace_async + async def delete_authorization_rule( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + **kwargs: Any + ) -> None: + """Deletes a topic authorization rule. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_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, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_authorization_rule.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}" + } + + @distributed_trace_async + async def list_keys( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + **kwargs: Any + ) -> _models.AccessKeys: + """Gets the primary and secondary connection strings for the topic. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AccessKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.AccessKeys] = kwargs.pop("cls", None) + + request = build_list_keys_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + authorization_rule_name=authorization_rule_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) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("AccessKeys", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/ListKeys" + } + + @overload + async def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: _models.RegenerateAccessKeyParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AccessKeys: + """Regenerates primary or secondary connection strings for the topic. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Required. + :type parameters: + ~azure.mgmt.servicebus.v2022_01_10_preview.models.RegenerateAccessKeyParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AccessKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AccessKeys: + """Regenerates primary or secondary connection strings for the topic. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Required. + :type 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: AccessKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: Union[_models.RegenerateAccessKeyParameters, IO], + **kwargs: Any + ) -> _models.AccessKeys: + """Regenerates primary or secondary connection strings for the topic. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Is either a model + type or a IO type. Required. + :type parameters: + ~azure.mgmt.servicebus.v2022_01_10_preview.models.RegenerateAccessKeyParameters 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: AccessKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + 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: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AccessKeys] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RegenerateAccessKeyParameters") + + request = build_regenerate_keys_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.regenerate_keys.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("AccessKeys", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + regenerate_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/regenerateKeys" + } + + @distributed_trace + def list_by_namespace( + self, + resource_group_name: str, + namespace_name: str, + skip: Optional[int] = None, + top: Optional[int] = None, + **kwargs: Any + ) -> AsyncIterable["_models.SBTopic"]: + """Gets all the topics in a namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param skip: Skip is only used if a previous operation returned a partial result. If a previous + response contains a nextLink element, the value of the nextLink element will include a skip + parameter that specifies a starting point to use for subsequent calls. Default value is None. + :type skip: int + :param top: May be used to limit the number of results to the most recent N usageDetails. + Default value is None. + :type top: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either SBTopic or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2022_01_10_preview.models.SBTopic] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.SBTopicListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_namespace_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + skip=skip, + top=top, + api_version=api_version, + template_url=self.list_by_namespace.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("SBTopicListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_namespace.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics" + } + + @overload + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + parameters: _models.SBTopic, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBTopic: + """Creates a topic in the specified namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param parameters: Parameters supplied to create a topic resource. Required. + :type parameters: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SBTopic + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBTopic or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SBTopic + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBTopic: + """Creates a topic in the specified namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param parameters: Parameters supplied to create a topic resource. Required. + :type 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: SBTopic or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SBTopic + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + parameters: Union[_models.SBTopic, IO], + **kwargs: Any + ) -> _models.SBTopic: + """Creates a topic in the specified namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param parameters: Parameters supplied to create a topic resource. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SBTopic 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: SBTopic or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SBTopic + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + 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: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SBTopic] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBTopic") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_id=self._config.subscription_id, + 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) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SBTopic", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}" + } + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, namespace_name: str, topic_name: str, **kwargs: Any + ) -> None: + """Deletes a topic from the specified namespace and resource group. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_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, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_id=self._config.subscription_id, + 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) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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.ErrorResponse, 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.ServiceBus/namespaces/{namespaceName}/topics/{topicName}" + } + + @distributed_trace_async + async def get( + self, resource_group_name: str, namespace_name: str, topic_name: str, **kwargs: Any + ) -> _models.SBTopic: + """Returns a description for the specified topic. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBTopic or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SBTopic + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.SBTopic] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_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) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SBTopic", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/models/__init__.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/models/__init__.py new file mode 100644 index 0000000000000..f766e5ccef14d --- /dev/null +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/models/__init__.py @@ -0,0 +1,169 @@ +# 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 AccessKeys +from ._models_py3 import Action +from ._models_py3 import ArmDisasterRecovery +from ._models_py3 import ArmDisasterRecoveryListResult +from ._models_py3 import CheckNameAvailability +from ._models_py3 import CheckNameAvailabilityResult +from ._models_py3 import ConnectionState +from ._models_py3 import CorrelationFilter +from ._models_py3 import Encryption +from ._models_py3 import ErrorAdditionalInfo +from ._models_py3 import ErrorResponse +from ._models_py3 import ErrorResponseError +from ._models_py3 import FailoverProperties +from ._models_py3 import Identity +from ._models_py3 import KeyVaultProperties +from ._models_py3 import MessageCountDetails +from ._models_py3 import MigrationConfigListResult +from ._models_py3 import MigrationConfigProperties +from ._models_py3 import NWRuleSetIpRules +from ._models_py3 import NWRuleSetVirtualNetworkRules +from ._models_py3 import NetworkRuleSet +from ._models_py3 import NetworkRuleSetListResult +from ._models_py3 import Operation +from ._models_py3 import OperationDisplay +from ._models_py3 import OperationListResult +from ._models_py3 import PrivateEndpoint +from ._models_py3 import PrivateEndpointConnection +from ._models_py3 import PrivateEndpointConnectionListResult +from ._models_py3 import PrivateLinkResource +from ._models_py3 import PrivateLinkResourcesListResult +from ._models_py3 import ProxyResource +from ._models_py3 import RegenerateAccessKeyParameters +from ._models_py3 import Resource +from ._models_py3 import ResourceNamespacePatch +from ._models_py3 import Rule +from ._models_py3 import RuleListResult +from ._models_py3 import SBAuthorizationRule +from ._models_py3 import SBAuthorizationRuleListResult +from ._models_py3 import SBClientAffineProperties +from ._models_py3 import SBNamespace +from ._models_py3 import SBNamespaceListResult +from ._models_py3 import SBNamespaceUpdateParameters +from ._models_py3 import SBQueue +from ._models_py3 import SBQueueListResult +from ._models_py3 import SBSku +from ._models_py3 import SBSubscription +from ._models_py3 import SBSubscriptionListResult +from ._models_py3 import SBTopic +from ._models_py3 import SBTopicListResult +from ._models_py3 import SqlFilter +from ._models_py3 import SqlRuleAction +from ._models_py3 import Subnet +from ._models_py3 import SystemData +from ._models_py3 import TrackedResource +from ._models_py3 import UserAssignedIdentity +from ._models_py3 import UserAssignedIdentityProperties + +from ._service_bus_management_client_enums import AccessRights +from ._service_bus_management_client_enums import CreatedByType +from ._service_bus_management_client_enums import DefaultAction +from ._service_bus_management_client_enums import EndPointProvisioningState +from ._service_bus_management_client_enums import EntityStatus +from ._service_bus_management_client_enums import FilterType +from ._service_bus_management_client_enums import KeySource +from ._service_bus_management_client_enums import KeyType +from ._service_bus_management_client_enums import ManagedServiceIdentityType +from ._service_bus_management_client_enums import MigrationConfigurationName +from ._service_bus_management_client_enums import NetworkRuleIPAction +from ._service_bus_management_client_enums import PrivateLinkConnectionStatus +from ._service_bus_management_client_enums import ProvisioningStateDR +from ._service_bus_management_client_enums import PublicNetworkAccess +from ._service_bus_management_client_enums import PublicNetworkAccessFlag +from ._service_bus_management_client_enums import RoleDisasterRecovery +from ._service_bus_management_client_enums import SkuName +from ._service_bus_management_client_enums import SkuTier +from ._service_bus_management_client_enums import TlsVersion +from ._service_bus_management_client_enums import UnavailableReason +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "AccessKeys", + "Action", + "ArmDisasterRecovery", + "ArmDisasterRecoveryListResult", + "CheckNameAvailability", + "CheckNameAvailabilityResult", + "ConnectionState", + "CorrelationFilter", + "Encryption", + "ErrorAdditionalInfo", + "ErrorResponse", + "ErrorResponseError", + "FailoverProperties", + "Identity", + "KeyVaultProperties", + "MessageCountDetails", + "MigrationConfigListResult", + "MigrationConfigProperties", + "NWRuleSetIpRules", + "NWRuleSetVirtualNetworkRules", + "NetworkRuleSet", + "NetworkRuleSetListResult", + "Operation", + "OperationDisplay", + "OperationListResult", + "PrivateEndpoint", + "PrivateEndpointConnection", + "PrivateEndpointConnectionListResult", + "PrivateLinkResource", + "PrivateLinkResourcesListResult", + "ProxyResource", + "RegenerateAccessKeyParameters", + "Resource", + "ResourceNamespacePatch", + "Rule", + "RuleListResult", + "SBAuthorizationRule", + "SBAuthorizationRuleListResult", + "SBClientAffineProperties", + "SBNamespace", + "SBNamespaceListResult", + "SBNamespaceUpdateParameters", + "SBQueue", + "SBQueueListResult", + "SBSku", + "SBSubscription", + "SBSubscriptionListResult", + "SBTopic", + "SBTopicListResult", + "SqlFilter", + "SqlRuleAction", + "Subnet", + "SystemData", + "TrackedResource", + "UserAssignedIdentity", + "UserAssignedIdentityProperties", + "AccessRights", + "CreatedByType", + "DefaultAction", + "EndPointProvisioningState", + "EntityStatus", + "FilterType", + "KeySource", + "KeyType", + "ManagedServiceIdentityType", + "MigrationConfigurationName", + "NetworkRuleIPAction", + "PrivateLinkConnectionStatus", + "ProvisioningStateDR", + "PublicNetworkAccess", + "PublicNetworkAccessFlag", + "RoleDisasterRecovery", + "SkuName", + "SkuTier", + "TlsVersion", + "UnavailableReason", +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/models/_models_py3.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/models/_models_py3.py similarity index 64% rename from sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/models/_models_py3.py rename to sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/models/_models_py3.py index eee47e184d163..5fa71f2dcd083 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/models/_models_py3.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_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,17 +8,23 @@ # -------------------------------------------------------------------------- import datetime +import sys from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from ... import _serialization + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - import __init__ as _models + from .. import models as _models +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object -class AccessKeys(msrest.serialization.Model): +class AccessKeys(_serialization.Model): """Namespace/ServiceBus Connection String. Variables are only populated by the server, and will be ignored when sending a request. @@ -45,32 +52,28 @@ class AccessKeys(msrest.serialization.Model): """ _validation = { - 'primary_connection_string': {'readonly': True}, - 'secondary_connection_string': {'readonly': True}, - 'alias_primary_connection_string': {'readonly': True}, - 'alias_secondary_connection_string': {'readonly': True}, - 'primary_key': {'readonly': True}, - 'secondary_key': {'readonly': True}, - 'key_name': {'readonly': True}, + "primary_connection_string": {"readonly": True}, + "secondary_connection_string": {"readonly": True}, + "alias_primary_connection_string": {"readonly": True}, + "alias_secondary_connection_string": {"readonly": True}, + "primary_key": {"readonly": True}, + "secondary_key": {"readonly": True}, + "key_name": {"readonly": True}, } _attribute_map = { - 'primary_connection_string': {'key': 'primaryConnectionString', 'type': 'str'}, - 'secondary_connection_string': {'key': 'secondaryConnectionString', 'type': 'str'}, - 'alias_primary_connection_string': {'key': 'aliasPrimaryConnectionString', 'type': 'str'}, - 'alias_secondary_connection_string': {'key': 'aliasSecondaryConnectionString', 'type': 'str'}, - 'primary_key': {'key': 'primaryKey', 'type': 'str'}, - 'secondary_key': {'key': 'secondaryKey', 'type': 'str'}, - 'key_name': {'key': 'keyName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - """ - """ - super(AccessKeys, self).__init__(**kwargs) + "primary_connection_string": {"key": "primaryConnectionString", "type": "str"}, + "secondary_connection_string": {"key": "secondaryConnectionString", "type": "str"}, + "alias_primary_connection_string": {"key": "aliasPrimaryConnectionString", "type": "str"}, + "alias_secondary_connection_string": {"key": "aliasSecondaryConnectionString", "type": "str"}, + "primary_key": {"key": "primaryKey", "type": "str"}, + "secondary_key": {"key": "secondaryKey", "type": "str"}, + "key_name": {"key": "keyName", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.primary_connection_string = None self.secondary_connection_string = None self.alias_primary_connection_string = None @@ -80,7 +83,7 @@ def __init__( self.key_name = None -class Action(msrest.serialization.Model): +class Action(_serialization.Model): """Represents the filter actions which are allowed for the transformation of a message that have been matched by a filter expression. :ivar sql_expression: SQL expression. e.g. MyProperty='ABC'. @@ -94,9 +97,9 @@ class Action(msrest.serialization.Model): """ _attribute_map = { - 'sql_expression': {'key': 'sqlExpression', 'type': 'str'}, - 'compatibility_level': {'key': 'compatibilityLevel', 'type': 'int'}, - 'requires_preprocessing': {'key': 'requiresPreprocessing', 'type': 'bool'}, + "sql_expression": {"key": "sqlExpression", "type": "str"}, + "compatibility_level": {"key": "compatibilityLevel", "type": "int"}, + "requires_preprocessing": {"key": "requiresPreprocessing", "type": "bool"}, } def __init__( @@ -104,7 +107,7 @@ def __init__( *, sql_expression: Optional[str] = None, compatibility_level: Optional[int] = None, - requires_preprocessing: Optional[bool] = True, + requires_preprocessing: bool = True, **kwargs ): """ @@ -117,13 +120,13 @@ def __init__( preprocessing. :paramtype requires_preprocessing: bool """ - super(Action, self).__init__(**kwargs) + super().__init__(**kwargs) self.sql_expression = sql_expression self.compatibility_level = compatibility_level self.requires_preprocessing = requires_preprocessing -class ProxyResource(msrest.serialization.Model): +class ProxyResource(_serialization.Model): """Common fields that are returned in the response for all Azure Resource Manager resources. Variables are only populated by the server, and will be ignored when sending a request. @@ -141,26 +144,22 @@ class ProxyResource(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ProxyResource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -183,14 +182,14 @@ class ArmDisasterRecovery(ProxyResource): :ivar location: The geo-location where the resource lives. :vartype location: str :ivar system_data: The system meta data relating to this resource. - :vartype system_data: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SystemData + :vartype system_data: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SystemData :ivar provisioning_state: Provisioning state of the Alias(Disaster Recovery configuration) - possible values 'Accepted' or 'Succeeded' or 'Failed'. Known values are: "Accepted", - "Succeeded", "Failed". + "Succeeded", and "Failed". :vartype provisioning_state: str or - ~azure.mgmt.servicebus.v2022_01_01_preview.models.ProvisioningStateDR + ~azure.mgmt.servicebus.v2022_01_10_preview.models.ProvisioningStateDR :ivar pending_replication_operations_count: Number of entities pending to be replicated. - :vartype pending_replication_operations_count: long + :vartype pending_replication_operations_count: int :ivar partner_namespace: ARM Id of the Primary/Secondary eventhub namespace name, which is part of GEO DR pairing. :vartype partner_namespace: str @@ -198,41 +197,35 @@ class ArmDisasterRecovery(ProxyResource): pairing. :vartype alternate_name: str :ivar role: role of namespace in GEO DR - possible values 'Primary' or 'PrimaryNotReplicating' - or 'Secondary'. Known values are: "Primary", "PrimaryNotReplicating", "Secondary". - :vartype role: str or ~azure.mgmt.servicebus.v2022_01_01_preview.models.RoleDisasterRecovery + or 'Secondary'. Known values are: "Primary", "PrimaryNotReplicating", and "Secondary". + :vartype role: str or ~azure.mgmt.servicebus.v2022_01_10_preview.models.RoleDisasterRecovery """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'readonly': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'pending_replication_operations_count': {'readonly': True}, - 'role': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"readonly": True}, + "system_data": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "pending_replication_operations_count": {"readonly": True}, + "role": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'pending_replication_operations_count': {'key': 'properties.pendingReplicationOperationsCount', 'type': 'long'}, - 'partner_namespace': {'key': 'properties.partnerNamespace', 'type': 'str'}, - 'alternate_name': {'key': 'properties.alternateName', 'type': 'str'}, - 'role': {'key': 'properties.role', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "pending_replication_operations_count": {"key": "properties.pendingReplicationOperationsCount", "type": "int"}, + "partner_namespace": {"key": "properties.partnerNamespace", "type": "str"}, + "alternate_name": {"key": "properties.alternateName", "type": "str"}, + "role": {"key": "properties.role", "type": "str"}, } - def __init__( - self, - *, - partner_namespace: Optional[str] = None, - alternate_name: Optional[str] = None, - **kwargs - ): + def __init__(self, *, partner_namespace: Optional[str] = None, alternate_name: Optional[str] = None, **kwargs): """ :keyword partner_namespace: ARM Id of the Primary/Secondary eventhub namespace name, which is part of GEO DR pairing. @@ -241,7 +234,7 @@ def __init__( pairing. :paramtype alternate_name: str """ - super(ArmDisasterRecovery, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.provisioning_state = None self.pending_replication_operations_count = None @@ -250,78 +243,68 @@ def __init__( self.role = None -class ArmDisasterRecoveryListResult(msrest.serialization.Model): +class ArmDisasterRecoveryListResult(_serialization.Model): """The result of the List Alias(Disaster Recovery configuration) operation. Variables are only populated by the server, and will be ignored when sending a request. :ivar value: List of Alias(Disaster Recovery configurations). - :vartype value: list[~azure.mgmt.servicebus.v2022_01_01_preview.models.ArmDisasterRecovery] + :vartype value: list[~azure.mgmt.servicebus.v2022_01_10_preview.models.ArmDisasterRecovery] :ivar next_link: Link to the next set of results. Not empty if Value contains incomplete list of Alias(Disaster Recovery configuration). :vartype next_link: str """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[ArmDisasterRecovery]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ArmDisasterRecovery]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["_models.ArmDisasterRecovery"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.ArmDisasterRecovery"]] = None, **kwargs): """ :keyword value: List of Alias(Disaster Recovery configurations). - :paramtype value: list[~azure.mgmt.servicebus.v2022_01_01_preview.models.ArmDisasterRecovery] + :paramtype value: list[~azure.mgmt.servicebus.v2022_01_10_preview.models.ArmDisasterRecovery] """ - super(ArmDisasterRecoveryListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class CheckNameAvailability(msrest.serialization.Model): +class CheckNameAvailability(_serialization.Model): """Description of a Check Name availability request properties. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The Name to check the namespace name availability and The namespace name - can contain only letters, numbers, and hyphens. The namespace must start with a letter, and it - must end with a letter or number. + :ivar name: The Name to check the namespace name availability and The namespace name can + contain only letters, numbers, and hyphens. The namespace must start with a letter, and it must + end with a letter or number. 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 to check the namespace name availability and The namespace - name can contain only letters, numbers, and hyphens. The namespace must start with a letter, - and it must end with a letter or number. + :keyword name: The Name to check the namespace name availability and The namespace name can + contain only letters, numbers, and hyphens. The namespace must start with a letter, and it must + end with a letter or number. Required. :paramtype name: str """ - super(CheckNameAvailability, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class CheckNameAvailabilityResult(msrest.serialization.Model): +class CheckNameAvailabilityResult(_serialization.Model): """Description of a Check Name availability request properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -332,19 +315,19 @@ class CheckNameAvailabilityResult(msrest.serialization.Model): available; otherwise, false. :vartype name_available: bool :ivar reason: The reason for unavailability of a namespace. Known values are: "None", - "InvalidName", "SubscriptionIsDisabled", "NameInUse", "NameInLockdown", + "InvalidName", "SubscriptionIsDisabled", "NameInUse", "NameInLockdown", and "TooManyNamespaceInCurrentSubscription". - :vartype reason: str or ~azure.mgmt.servicebus.v2022_01_01_preview.models.UnavailableReason + :vartype reason: str or ~azure.mgmt.servicebus.v2022_01_10_preview.models.UnavailableReason """ _validation = { - 'message': {'readonly': True}, + "message": {"readonly": True}, } _attribute_map = { - 'message': {'key': 'message', 'type': 'str'}, - '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"}, } def __init__( @@ -359,30 +342,30 @@ def __init__( available; otherwise, false. :paramtype name_available: bool :keyword reason: The reason for unavailability of a namespace. Known values are: "None", - "InvalidName", "SubscriptionIsDisabled", "NameInUse", "NameInLockdown", + "InvalidName", "SubscriptionIsDisabled", "NameInUse", "NameInLockdown", and "TooManyNamespaceInCurrentSubscription". - :paramtype reason: str or ~azure.mgmt.servicebus.v2022_01_01_preview.models.UnavailableReason + :paramtype reason: str or ~azure.mgmt.servicebus.v2022_01_10_preview.models.UnavailableReason """ - super(CheckNameAvailabilityResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.message = None self.name_available = name_available self.reason = reason -class ConnectionState(msrest.serialization.Model): +class ConnectionState(_serialization.Model): """ConnectionState information. :ivar status: Status of the connection. Known values are: "Pending", "Approved", "Rejected", - "Disconnected". + and "Disconnected". :vartype status: str or - ~azure.mgmt.servicebus.v2022_01_01_preview.models.PrivateLinkConnectionStatus + ~azure.mgmt.servicebus.v2022_01_10_preview.models.PrivateLinkConnectionStatus :ivar description: Description of the connection state. :vartype description: str """ _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, + "status": {"key": "status", "type": "str"}, + "description": {"key": "description", "type": "str"}, } def __init__( @@ -394,18 +377,18 @@ def __init__( ): """ :keyword status: Status of the connection. Known values are: "Pending", "Approved", "Rejected", - "Disconnected". + and "Disconnected". :paramtype status: str or - ~azure.mgmt.servicebus.v2022_01_01_preview.models.PrivateLinkConnectionStatus + ~azure.mgmt.servicebus.v2022_01_10_preview.models.PrivateLinkConnectionStatus :keyword description: Description of the connection state. :paramtype description: str """ - super(ConnectionState, self).__init__(**kwargs) + super().__init__(**kwargs) self.status = status self.description = description -class CorrelationFilter(msrest.serialization.Model): +class CorrelationFilter(_serialization.Model): """Represents the correlation filter expression. :ivar properties: dictionary object for custom filters. @@ -432,16 +415,16 @@ class CorrelationFilter(msrest.serialization.Model): """ _attribute_map = { - 'properties': {'key': 'properties', 'type': '{str}'}, - 'correlation_id': {'key': 'correlationId', 'type': 'str'}, - 'message_id': {'key': 'messageId', 'type': 'str'}, - 'to': {'key': 'to', 'type': 'str'}, - 'reply_to': {'key': 'replyTo', 'type': 'str'}, - 'label': {'key': 'label', 'type': 'str'}, - 'session_id': {'key': 'sessionId', 'type': 'str'}, - 'reply_to_session_id': {'key': 'replyToSessionId', 'type': 'str'}, - 'content_type': {'key': 'contentType', 'type': 'str'}, - 'requires_preprocessing': {'key': 'requiresPreprocessing', 'type': 'bool'}, + "properties": {"key": "properties", "type": "{str}"}, + "correlation_id": {"key": "correlationId", "type": "str"}, + "message_id": {"key": "messageId", "type": "str"}, + "to": {"key": "to", "type": "str"}, + "reply_to": {"key": "replyTo", "type": "str"}, + "label": {"key": "label", "type": "str"}, + "session_id": {"key": "sessionId", "type": "str"}, + "reply_to_session_id": {"key": "replyToSessionId", "type": "str"}, + "content_type": {"key": "contentType", "type": "str"}, + "requires_preprocessing": {"key": "requiresPreprocessing", "type": "bool"}, } def __init__( @@ -456,7 +439,7 @@ def __init__( session_id: Optional[str] = None, reply_to_session_id: Optional[str] = None, content_type: Optional[str] = None, - requires_preprocessing: Optional[bool] = True, + requires_preprocessing: bool = True, **kwargs ): """ @@ -482,7 +465,7 @@ def __init__( preprocessing. :paramtype requires_preprocessing: bool """ - super(CorrelationFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties self.correlation_id = correlation_id self.message_id = message_id @@ -495,51 +478,51 @@ def __init__( self.requires_preprocessing = requires_preprocessing -class Encryption(msrest.serialization.Model): +class Encryption(_serialization.Model): """Properties to configure Encryption. :ivar key_vault_properties: Properties of KeyVault. :vartype key_vault_properties: - list[~azure.mgmt.servicebus.v2022_01_01_preview.models.KeyVaultProperties] - :ivar key_source: Enumerates the possible value of keySource for Encryption. Known values are: - "Microsoft.KeyVault". Default value: "Microsoft.KeyVault". - :vartype key_source: str or ~azure.mgmt.servicebus.v2022_01_01_preview.models.KeySource + list[~azure.mgmt.servicebus.v2022_01_10_preview.models.KeyVaultProperties] + :ivar key_source: Enumerates the possible value of keySource for Encryption. + "Microsoft.KeyVault" + :vartype key_source: str or ~azure.mgmt.servicebus.v2022_01_10_preview.models.KeySource :ivar require_infrastructure_encryption: Enable Infrastructure Encryption (Double Encryption). :vartype require_infrastructure_encryption: bool """ _attribute_map = { - 'key_vault_properties': {'key': 'keyVaultProperties', 'type': '[KeyVaultProperties]'}, - 'key_source': {'key': 'keySource', 'type': 'str'}, - 'require_infrastructure_encryption': {'key': 'requireInfrastructureEncryption', 'type': 'bool'}, + "key_vault_properties": {"key": "keyVaultProperties", "type": "[KeyVaultProperties]"}, + "key_source": {"key": "keySource", "type": "str"}, + "require_infrastructure_encryption": {"key": "requireInfrastructureEncryption", "type": "bool"}, } def __init__( self, *, key_vault_properties: Optional[List["_models.KeyVaultProperties"]] = None, - key_source: Optional[Union[str, "_models.KeySource"]] = "Microsoft.KeyVault", + key_source: Union[str, "_models.KeySource"] = "Microsoft.KeyVault", require_infrastructure_encryption: Optional[bool] = None, **kwargs ): """ :keyword key_vault_properties: Properties of KeyVault. :paramtype key_vault_properties: - list[~azure.mgmt.servicebus.v2022_01_01_preview.models.KeyVaultProperties] - :keyword key_source: Enumerates the possible value of keySource for Encryption. Known values - are: "Microsoft.KeyVault". Default value: "Microsoft.KeyVault". - :paramtype key_source: str or ~azure.mgmt.servicebus.v2022_01_01_preview.models.KeySource + list[~azure.mgmt.servicebus.v2022_01_10_preview.models.KeyVaultProperties] + :keyword key_source: Enumerates the possible value of keySource for Encryption. + "Microsoft.KeyVault" + :paramtype key_source: str or ~azure.mgmt.servicebus.v2022_01_10_preview.models.KeySource :keyword require_infrastructure_encryption: Enable Infrastructure Encryption (Double Encryption). :paramtype require_infrastructure_encryption: bool """ - super(Encryption, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_vault_properties = key_vault_properties self.key_source = key_source self.require_infrastructure_encryption = require_infrastructure_encryption -class ErrorAdditionalInfo(msrest.serialization.Model): +class ErrorAdditionalInfo(_serialization.Model): """The resource management error additional info. Variables are only populated by the server, and will be ignored when sending a request. @@ -547,56 +530,47 @@ class ErrorAdditionalInfo(msrest.serialization.Model): :ivar type: The additional info type. :vartype type: str :ivar info: The additional info. - :vartype info: any + :vartype info: JSON """ _validation = { - 'type': {'readonly': True}, - 'info': {'readonly': True}, + "type": {"readonly": True}, + "info": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'info': {'key': 'info', 'type': 'object'}, + "type": {"key": "type", "type": "str"}, + "info": {"key": "info", "type": "object"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorAdditionalInfo, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.type = None self.info = None -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_serialization.Model): """The resource management error response. :ivar error: The error object. - :vartype error: ~azure.mgmt.servicebus.v2022_01_01_preview.models.ErrorResponseError + :vartype error: ~azure.mgmt.servicebus.v2022_01_10_preview.models.ErrorResponseError """ _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorResponseError'}, + "error": {"key": "error", "type": "ErrorResponseError"}, } - def __init__( - self, - *, - error: Optional["_models.ErrorResponseError"] = None, - **kwargs - ): + def __init__(self, *, error: Optional["_models.ErrorResponseError"] = None, **kwargs): """ :keyword error: The error object. - :paramtype error: ~azure.mgmt.servicebus.v2022_01_01_preview.models.ErrorResponseError + :paramtype error: ~azure.mgmt.servicebus.v2022_01_10_preview.models.ErrorResponseError """ - super(ErrorResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.error = error -class ErrorResponseError(msrest.serialization.Model): +class ErrorResponseError(_serialization.Model): """The error object. Variables are only populated by the server, and will be ignored when sending a request. @@ -608,35 +582,31 @@ class ErrorResponseError(msrest.serialization.Model): :ivar target: The error target. :vartype target: str :ivar details: The error details. - :vartype details: list[~azure.mgmt.servicebus.v2022_01_01_preview.models.ErrorResponse] + :vartype details: list[~azure.mgmt.servicebus.v2022_01_10_preview.models.ErrorResponse] :ivar additional_info: The error additional info. :vartype additional_info: - list[~azure.mgmt.servicebus.v2022_01_01_preview.models.ErrorAdditionalInfo] + list[~azure.mgmt.servicebus.v2022_01_10_preview.models.ErrorAdditionalInfo] """ _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - 'details': {'readonly': True}, - 'additional_info': {'readonly': True}, + "code": {"readonly": True}, + "message": {"readonly": True}, + "target": {"readonly": True}, + "details": {"readonly": True}, + "additional_info": {"readonly": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ErrorResponse]'}, - 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[ErrorResponse]"}, + "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorResponseError, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.code = None self.message = None self.target = None @@ -644,7 +614,7 @@ def __init__( self.additional_info = None -class FailoverProperties(msrest.serialization.Model): +class FailoverProperties(_serialization.Model): """Safe failover is to indicate the service should wait for pending replication to finish before switching to the secondary. :ivar is_safe_failover: Safe failover is to indicate the service should wait for pending @@ -653,25 +623,20 @@ class FailoverProperties(msrest.serialization.Model): """ _attribute_map = { - 'is_safe_failover': {'key': 'properties.IsSafeFailover', 'type': 'bool'}, + "is_safe_failover": {"key": "properties.IsSafeFailover", "type": "bool"}, } - def __init__( - self, - *, - is_safe_failover: Optional[bool] = None, - **kwargs - ): + def __init__(self, *, is_safe_failover: Optional[bool] = None, **kwargs): """ :keyword is_safe_failover: Safe failover is to indicate the service should wait for pending replication to finish before switching to the secondary. :paramtype is_safe_failover: bool """ - super(FailoverProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.is_safe_failover = is_safe_failover -class Identity(msrest.serialization.Model): +class Identity(_serialization.Model): """Properties to configure User Assigned Identities for Bring your Own Keys. Variables are only populated by the server, and will be ignored when sending a request. @@ -681,24 +646,24 @@ class Identity(msrest.serialization.Model): :ivar tenant_id: TenantId from the KeyVault. :vartype tenant_id: str :ivar type: Type of managed service identity. Known values are: "SystemAssigned", - "UserAssigned", "SystemAssigned, UserAssigned", "None". + "UserAssigned", "SystemAssigned, UserAssigned", and "None". :vartype type: str or - ~azure.mgmt.servicebus.v2022_01_01_preview.models.ManagedServiceIdentityType + ~azure.mgmt.servicebus.v2022_01_10_preview.models.ManagedServiceIdentityType :ivar user_assigned_identities: Properties for User Assigned Identities. :vartype user_assigned_identities: dict[str, - ~azure.mgmt.servicebus.v2022_01_01_preview.models.UserAssignedIdentity] + ~azure.mgmt.servicebus.v2022_01_10_preview.models.UserAssignedIdentity] """ _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': '{UserAssignedIdentity}'}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "user_assigned_identities": {"key": "userAssignedIdentities", "type": "{UserAssignedIdentity}"}, } def __init__( @@ -710,21 +675,21 @@ def __init__( ): """ :keyword type: Type of managed service identity. Known values are: "SystemAssigned", - "UserAssigned", "SystemAssigned, UserAssigned", "None". + "UserAssigned", "SystemAssigned, UserAssigned", and "None". :paramtype type: str or - ~azure.mgmt.servicebus.v2022_01_01_preview.models.ManagedServiceIdentityType + ~azure.mgmt.servicebus.v2022_01_10_preview.models.ManagedServiceIdentityType :keyword user_assigned_identities: Properties for User Assigned Identities. :paramtype user_assigned_identities: dict[str, - ~azure.mgmt.servicebus.v2022_01_01_preview.models.UserAssignedIdentity] + ~azure.mgmt.servicebus.v2022_01_10_preview.models.UserAssignedIdentity] """ - super(Identity, 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 KeyVaultProperties(msrest.serialization.Model): +class KeyVaultProperties(_serialization.Model): """Properties to configure keyVault Properties. :ivar key_name: Name of the Key from KeyVault. @@ -735,14 +700,14 @@ class KeyVaultProperties(msrest.serialization.Model): :vartype key_version: str :ivar identity: :vartype identity: - ~azure.mgmt.servicebus.v2022_01_01_preview.models.UserAssignedIdentityProperties + ~azure.mgmt.servicebus.v2022_01_10_preview.models.UserAssignedIdentityProperties """ _attribute_map = { - 'key_name': {'key': 'keyName', 'type': 'str'}, - 'key_vault_uri': {'key': 'keyVaultUri', 'type': 'str'}, - 'key_version': {'key': 'keyVersion', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'UserAssignedIdentityProperties'}, + "key_name": {"key": "keyName", "type": "str"}, + "key_vault_uri": {"key": "keyVaultUri", "type": "str"}, + "key_version": {"key": "keyVersion", "type": "str"}, + "identity": {"key": "identity", "type": "UserAssignedIdentityProperties"}, } def __init__( @@ -763,56 +728,52 @@ def __init__( :paramtype key_version: str :keyword identity: :paramtype identity: - ~azure.mgmt.servicebus.v2022_01_01_preview.models.UserAssignedIdentityProperties + ~azure.mgmt.servicebus.v2022_01_10_preview.models.UserAssignedIdentityProperties """ - super(KeyVaultProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_name = key_name self.key_vault_uri = key_vault_uri self.key_version = key_version self.identity = identity -class MessageCountDetails(msrest.serialization.Model): +class MessageCountDetails(_serialization.Model): """Message Count Details. Variables are only populated by the server, and will be ignored when sending a request. :ivar active_message_count: Number of active messages in the queue, topic, or subscription. - :vartype active_message_count: long + :vartype active_message_count: int :ivar dead_letter_message_count: Number of messages that are dead lettered. - :vartype dead_letter_message_count: long + :vartype dead_letter_message_count: int :ivar scheduled_message_count: Number of scheduled messages. - :vartype scheduled_message_count: long + :vartype scheduled_message_count: int :ivar transfer_message_count: Number of messages transferred to another queue, topic, or subscription. - :vartype transfer_message_count: long + :vartype transfer_message_count: int :ivar transfer_dead_letter_message_count: Number of messages transferred into dead letters. - :vartype transfer_dead_letter_message_count: long + :vartype transfer_dead_letter_message_count: int """ _validation = { - 'active_message_count': {'readonly': True}, - 'dead_letter_message_count': {'readonly': True}, - 'scheduled_message_count': {'readonly': True}, - 'transfer_message_count': {'readonly': True}, - 'transfer_dead_letter_message_count': {'readonly': True}, + "active_message_count": {"readonly": True}, + "dead_letter_message_count": {"readonly": True}, + "scheduled_message_count": {"readonly": True}, + "transfer_message_count": {"readonly": True}, + "transfer_dead_letter_message_count": {"readonly": True}, } _attribute_map = { - 'active_message_count': {'key': 'activeMessageCount', 'type': 'long'}, - 'dead_letter_message_count': {'key': 'deadLetterMessageCount', 'type': 'long'}, - 'scheduled_message_count': {'key': 'scheduledMessageCount', 'type': 'long'}, - 'transfer_message_count': {'key': 'transferMessageCount', 'type': 'long'}, - 'transfer_dead_letter_message_count': {'key': 'transferDeadLetterMessageCount', 'type': 'long'}, + "active_message_count": {"key": "activeMessageCount", "type": "int"}, + "dead_letter_message_count": {"key": "deadLetterMessageCount", "type": "int"}, + "scheduled_message_count": {"key": "scheduledMessageCount", "type": "int"}, + "transfer_message_count": {"key": "transferMessageCount", "type": "int"}, + "transfer_dead_letter_message_count": {"key": "transferDeadLetterMessageCount", "type": "int"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(MessageCountDetails, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.active_message_count = None self.dead_letter_message_count = None self.scheduled_message_count = None @@ -820,40 +781,35 @@ def __init__( self.transfer_dead_letter_message_count = None -class MigrationConfigListResult(msrest.serialization.Model): +class MigrationConfigListResult(_serialization.Model): """The result of the List migrationConfigurations operation. Variables are only populated by the server, and will be ignored when sending a request. :ivar value: List of Migration Configs. :vartype value: - list[~azure.mgmt.servicebus.v2022_01_01_preview.models.MigrationConfigProperties] + list[~azure.mgmt.servicebus.v2022_01_10_preview.models.MigrationConfigProperties] :ivar next_link: Link to the next set of results. Not empty if Value contains incomplete list of migrationConfigurations. :vartype next_link: str """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[MigrationConfigProperties]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[MigrationConfigProperties]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["_models.MigrationConfigProperties"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.MigrationConfigProperties"]] = None, **kwargs): """ :keyword value: List of Migration Configs. :paramtype value: - list[~azure.mgmt.servicebus.v2022_01_01_preview.models.MigrationConfigProperties] + list[~azure.mgmt.servicebus.v2022_01_10_preview.models.MigrationConfigProperties] """ - super(MigrationConfigListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None @@ -874,11 +830,11 @@ class MigrationConfigProperties(ProxyResource): :ivar location: The geo-location where the resource lives. :vartype location: str :ivar system_data: The system meta data relating to this resource. - :vartype system_data: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SystemData + :vartype system_data: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SystemData :ivar provisioning_state: Provisioning state of Migration Configuration. :vartype provisioning_state: str :ivar pending_replication_operations_count: Number of entities pending to be replicated. - :vartype pending_replication_operations_count: long + :vartype pending_replication_operations_count: int :ivar target_namespace: Existing premium Namespace ARM Id name which has no entities, will be used for migration. :vartype target_namespace: str @@ -890,36 +846,30 @@ class MigrationConfigProperties(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'readonly': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'pending_replication_operations_count': {'readonly': True}, - 'migration_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"readonly": True}, + "system_data": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "pending_replication_operations_count": {"readonly": True}, + "migration_state": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'pending_replication_operations_count': {'key': 'properties.pendingReplicationOperationsCount', 'type': 'long'}, - 'target_namespace': {'key': 'properties.targetNamespace', 'type': 'str'}, - 'post_migration_name': {'key': 'properties.postMigrationName', 'type': 'str'}, - 'migration_state': {'key': 'properties.migrationState', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "pending_replication_operations_count": {"key": "properties.pendingReplicationOperationsCount", "type": "int"}, + "target_namespace": {"key": "properties.targetNamespace", "type": "str"}, + "post_migration_name": {"key": "properties.postMigrationName", "type": "str"}, + "migration_state": {"key": "properties.migrationState", "type": "str"}, } - def __init__( - self, - *, - target_namespace: Optional[str] = None, - post_migration_name: Optional[str] = None, - **kwargs - ): + def __init__(self, *, target_namespace: Optional[str] = None, post_migration_name: Optional[str] = None, **kwargs): """ :keyword target_namespace: Existing premium Namespace ARM Id name which has no entities, will be used for migration. @@ -927,7 +877,7 @@ def __init__( :keyword post_migration_name: Name to access Standard Namespace after migration. :paramtype post_migration_name: str """ - super(MigrationConfigProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.provisioning_state = None self.pending_replication_operations_count = None @@ -952,42 +902,43 @@ class NetworkRuleSet(ProxyResource): :ivar location: The geo-location where the resource lives. :vartype location: str :ivar system_data: The system meta data relating to this resource. - :vartype system_data: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SystemData + :vartype system_data: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SystemData :ivar trusted_service_access_enabled: Value that indicates whether Trusted Service Access is Enabled or not. :vartype trusted_service_access_enabled: bool - :ivar default_action: Default Action for Network Rule Set. Known values are: "Allow", "Deny". - :vartype default_action: str or ~azure.mgmt.servicebus.v2022_01_01_preview.models.DefaultAction + :ivar default_action: Default Action for Network Rule Set. Known values are: "Allow" and + "Deny". + :vartype default_action: str or ~azure.mgmt.servicebus.v2022_01_10_preview.models.DefaultAction :ivar virtual_network_rules: List VirtualNetwork Rules. :vartype virtual_network_rules: - list[~azure.mgmt.servicebus.v2022_01_01_preview.models.NWRuleSetVirtualNetworkRules] + list[~azure.mgmt.servicebus.v2022_01_10_preview.models.NWRuleSetVirtualNetworkRules] :ivar ip_rules: List of IpRules. - :vartype ip_rules: list[~azure.mgmt.servicebus.v2022_01_01_preview.models.NWRuleSetIpRules] + :vartype ip_rules: list[~azure.mgmt.servicebus.v2022_01_10_preview.models.NWRuleSetIpRules] :ivar public_network_access: This determines if traffic is allowed over public network. By - default it is enabled. Known values are: "Enabled", "Disabled". Default value: "Enabled". + default it is enabled. Known values are: "Enabled" and "Disabled". :vartype public_network_access: str or - ~azure.mgmt.servicebus.v2022_01_01_preview.models.PublicNetworkAccessFlag + ~azure.mgmt.servicebus.v2022_01_10_preview.models.PublicNetworkAccessFlag """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'readonly': True}, - 'system_data': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"readonly": 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'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'trusted_service_access_enabled': {'key': 'properties.trustedServiceAccessEnabled', 'type': 'bool'}, - 'default_action': {'key': 'properties.defaultAction', 'type': 'str'}, - 'virtual_network_rules': {'key': 'properties.virtualNetworkRules', 'type': '[NWRuleSetVirtualNetworkRules]'}, - 'ip_rules': {'key': 'properties.ipRules', 'type': '[NWRuleSetIpRules]'}, - 'public_network_access': {'key': 'properties.publicNetworkAccess', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "trusted_service_access_enabled": {"key": "properties.trustedServiceAccessEnabled", "type": "bool"}, + "default_action": {"key": "properties.defaultAction", "type": "str"}, + "virtual_network_rules": {"key": "properties.virtualNetworkRules", "type": "[NWRuleSetVirtualNetworkRules]"}, + "ip_rules": {"key": "properties.ipRules", "type": "[NWRuleSetIpRules]"}, + "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, } def __init__( @@ -997,28 +948,28 @@ def __init__( default_action: Optional[Union[str, "_models.DefaultAction"]] = None, virtual_network_rules: Optional[List["_models.NWRuleSetVirtualNetworkRules"]] = None, ip_rules: Optional[List["_models.NWRuleSetIpRules"]] = None, - public_network_access: Optional[Union[str, "_models.PublicNetworkAccessFlag"]] = "Enabled", + public_network_access: Union[str, "_models.PublicNetworkAccessFlag"] = "Enabled", **kwargs ): """ :keyword trusted_service_access_enabled: Value that indicates whether Trusted Service Access is Enabled or not. :paramtype trusted_service_access_enabled: bool - :keyword default_action: Default Action for Network Rule Set. Known values are: "Allow", + :keyword default_action: Default Action for Network Rule Set. Known values are: "Allow" and "Deny". :paramtype default_action: str or - ~azure.mgmt.servicebus.v2022_01_01_preview.models.DefaultAction + ~azure.mgmt.servicebus.v2022_01_10_preview.models.DefaultAction :keyword virtual_network_rules: List VirtualNetwork Rules. :paramtype virtual_network_rules: - list[~azure.mgmt.servicebus.v2022_01_01_preview.models.NWRuleSetVirtualNetworkRules] + list[~azure.mgmt.servicebus.v2022_01_10_preview.models.NWRuleSetVirtualNetworkRules] :keyword ip_rules: List of IpRules. - :paramtype ip_rules: list[~azure.mgmt.servicebus.v2022_01_01_preview.models.NWRuleSetIpRules] + :paramtype ip_rules: list[~azure.mgmt.servicebus.v2022_01_10_preview.models.NWRuleSetIpRules] :keyword public_network_access: This determines if traffic is allowed over public network. By - default it is enabled. Known values are: "Enabled", "Disabled". Default value: "Enabled". + default it is enabled. Known values are: "Enabled" and "Disabled". :paramtype public_network_access: str or - ~azure.mgmt.servicebus.v2022_01_01_preview.models.PublicNetworkAccessFlag + ~azure.mgmt.servicebus.v2022_01_10_preview.models.PublicNetworkAccessFlag """ - super(NetworkRuleSet, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.trusted_service_access_enabled = trusted_service_access_enabled self.default_action = default_action @@ -1027,85 +978,77 @@ def __init__( self.public_network_access = public_network_access -class NetworkRuleSetListResult(msrest.serialization.Model): +class NetworkRuleSetListResult(_serialization.Model): """The response of the List NetworkRuleSet operation. :ivar value: Result of the List NetworkRuleSet operation. - :vartype value: list[~azure.mgmt.servicebus.v2022_01_01_preview.models.NetworkRuleSet] + :vartype value: list[~azure.mgmt.servicebus.v2022_01_10_preview.models.NetworkRuleSet] :ivar next_link: Link to the next set of results. Not empty if Value contains incomplete list of NetworkRuleSet. :vartype next_link: str """ _attribute_map = { - 'value': {'key': 'value', 'type': '[NetworkRuleSet]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[NetworkRuleSet]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["_models.NetworkRuleSet"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.NetworkRuleSet"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Result of the List NetworkRuleSet operation. - :paramtype value: list[~azure.mgmt.servicebus.v2022_01_01_preview.models.NetworkRuleSet] + :paramtype value: list[~azure.mgmt.servicebus.v2022_01_10_preview.models.NetworkRuleSet] :keyword next_link: Link to the next set of results. Not empty if Value contains incomplete list of NetworkRuleSet. :paramtype next_link: str """ - super(NetworkRuleSetListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class NWRuleSetIpRules(msrest.serialization.Model): +class NWRuleSetIpRules(_serialization.Model): """Description of NetWorkRuleSet - IpRules resource. :ivar ip_mask: IP Mask. :vartype ip_mask: str - :ivar action: The IP Filter Action. Known values are: "Allow". Default value: "Allow". - :vartype action: str or ~azure.mgmt.servicebus.v2022_01_01_preview.models.NetworkRuleIPAction + :ivar action: The IP Filter Action. "Allow" + :vartype action: str or ~azure.mgmt.servicebus.v2022_01_10_preview.models.NetworkRuleIPAction """ _attribute_map = { - 'ip_mask': {'key': 'ipMask', 'type': 'str'}, - 'action': {'key': 'action', 'type': 'str'}, + "ip_mask": {"key": "ipMask", "type": "str"}, + "action": {"key": "action", "type": "str"}, } def __init__( - self, - *, - ip_mask: Optional[str] = None, - action: Optional[Union[str, "_models.NetworkRuleIPAction"]] = "Allow", - **kwargs + self, *, ip_mask: Optional[str] = None, action: Union[str, "_models.NetworkRuleIPAction"] = "Allow", **kwargs ): """ :keyword ip_mask: IP Mask. :paramtype ip_mask: str - :keyword action: The IP Filter Action. Known values are: "Allow". Default value: "Allow". - :paramtype action: str or ~azure.mgmt.servicebus.v2022_01_01_preview.models.NetworkRuleIPAction + :keyword action: The IP Filter Action. "Allow" + :paramtype action: str or ~azure.mgmt.servicebus.v2022_01_10_preview.models.NetworkRuleIPAction """ - super(NWRuleSetIpRules, self).__init__(**kwargs) + super().__init__(**kwargs) self.ip_mask = ip_mask self.action = action -class NWRuleSetVirtualNetworkRules(msrest.serialization.Model): +class NWRuleSetVirtualNetworkRules(_serialization.Model): """Description of VirtualNetworkRules - NetworkRules resource. :ivar subnet: Subnet properties. - :vartype subnet: ~azure.mgmt.servicebus.v2022_01_01_preview.models.Subnet + :vartype subnet: ~azure.mgmt.servicebus.v2022_01_10_preview.models.Subnet :ivar ignore_missing_vnet_service_endpoint: Value that indicates whether to ignore missing VNet Service Endpoint. :vartype ignore_missing_vnet_service_endpoint: bool """ _attribute_map = { - 'subnet': {'key': 'subnet', 'type': 'Subnet'}, - 'ignore_missing_vnet_service_endpoint': {'key': 'ignoreMissingVnetServiceEndpoint', 'type': 'bool'}, + "subnet": {"key": "subnet", "type": "Subnet"}, + "ignore_missing_vnet_service_endpoint": {"key": "ignoreMissingVnetServiceEndpoint", "type": "bool"}, } def __init__( @@ -1117,17 +1060,17 @@ def __init__( ): """ :keyword subnet: Subnet properties. - :paramtype subnet: ~azure.mgmt.servicebus.v2022_01_01_preview.models.Subnet + :paramtype subnet: ~azure.mgmt.servicebus.v2022_01_10_preview.models.Subnet :keyword ignore_missing_vnet_service_endpoint: Value that indicates whether to ignore missing VNet Service Endpoint. :paramtype ignore_missing_vnet_service_endpoint: bool """ - super(NWRuleSetVirtualNetworkRules, self).__init__(**kwargs) + super().__init__(**kwargs) self.subnet = subnet self.ignore_missing_vnet_service_endpoint = ignore_missing_vnet_service_endpoint -class Operation(msrest.serialization.Model): +class Operation(_serialization.Model): """A Service Bus REST API operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -1137,23 +1080,23 @@ class Operation(msrest.serialization.Model): :ivar is_data_action: Indicates whether the operation is a data action. :vartype is_data_action: bool :ivar display: Display of the operation. - :vartype display: ~azure.mgmt.servicebus.v2022_01_01_preview.models.OperationDisplay + :vartype display: ~azure.mgmt.servicebus.v2022_01_10_preview.models.OperationDisplay :ivar origin: Origin of the operation. :vartype origin: str :ivar properties: Properties of the operation. - :vartype properties: any + :vartype properties: JSON """ _validation = { - 'name': {'readonly': True}, + "name": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - 'origin': {'key': 'origin', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'object'}, + "name": {"key": "name", "type": "str"}, + "is_data_action": {"key": "isDataAction", "type": "bool"}, + "display": {"key": "display", "type": "OperationDisplay"}, + "origin": {"key": "origin", "type": "str"}, + "properties": {"key": "properties", "type": "object"}, } def __init__( @@ -1162,20 +1105,20 @@ def __init__( is_data_action: Optional[bool] = None, display: Optional["_models.OperationDisplay"] = None, origin: Optional[str] = None, - properties: Optional[Any] = None, + properties: Optional[JSON] = None, **kwargs ): """ :keyword is_data_action: Indicates whether the operation is a data action. :paramtype is_data_action: bool :keyword display: Display of the operation. - :paramtype display: ~azure.mgmt.servicebus.v2022_01_01_preview.models.OperationDisplay + :paramtype display: ~azure.mgmt.servicebus.v2022_01_10_preview.models.OperationDisplay :keyword origin: Origin of the operation. :paramtype origin: str :keyword properties: Properties of the operation. - :paramtype properties: any + :paramtype properties: JSON """ - super(Operation, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = None self.is_data_action = is_data_action self.display = display @@ -1183,7 +1126,7 @@ def __init__( self.properties = properties -class OperationDisplay(msrest.serialization.Model): +class OperationDisplay(_serialization.Model): """Operation display payload. Variables are only populated by the server, and will be ignored when sending a request. @@ -1199,66 +1142,58 @@ 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 OperationListResult(msrest.serialization.Model): +class OperationListResult(_serialization.Model): """Result of the request to list ServiceBus 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 ServiceBus operations supported by the Microsoft.ServiceBus resource provider. - :vartype value: list[~azure.mgmt.servicebus.v2022_01_01_preview.models.Operation] + :vartype value: list[~azure.mgmt.servicebus.v2022_01_10_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}, + "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): """PrivateEndpoint information. :ivar id: The ARM identifier for Private Endpoint. @@ -1266,20 +1201,15 @@ class PrivateEndpoint(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - *, - id: Optional[str] = None, - **kwargs - ): + def __init__(self, *, id: Optional[str] = None, **kwargs): # pylint: disable=redefined-builtin """ :keyword id: The ARM identifier for Private Endpoint. :paramtype id: str """ - super(PrivateEndpoint, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id @@ -1299,35 +1229,38 @@ class PrivateEndpointConnection(ProxyResource): :ivar location: The geo-location where the resource lives. :vartype location: str :ivar system_data: The system meta data relating to this resource. - :vartype system_data: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SystemData + :vartype system_data: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SystemData :ivar private_endpoint: The Private Endpoint resource for this Connection. - :vartype private_endpoint: ~azure.mgmt.servicebus.v2022_01_01_preview.models.PrivateEndpoint + :vartype private_endpoint: ~azure.mgmt.servicebus.v2022_01_10_preview.models.PrivateEndpoint :ivar private_link_service_connection_state: Details about the state of the connection. :vartype private_link_service_connection_state: - ~azure.mgmt.servicebus.v2022_01_01_preview.models.ConnectionState + ~azure.mgmt.servicebus.v2022_01_10_preview.models.ConnectionState :ivar provisioning_state: Provisioning state of the Private Endpoint Connection. Known values - are: "Creating", "Updating", "Deleting", "Succeeded", "Canceled", "Failed". + are: "Creating", "Updating", "Deleting", "Succeeded", "Canceled", and "Failed". :vartype provisioning_state: str or - ~azure.mgmt.servicebus.v2022_01_01_preview.models.EndPointProvisioningState + ~azure.mgmt.servicebus.v2022_01_10_preview.models.EndPointProvisioningState """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'readonly': True}, - 'system_data': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"readonly": 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'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'private_endpoint': {'key': 'properties.privateEndpoint', 'type': 'PrivateEndpoint'}, - 'private_link_service_connection_state': {'key': 'properties.privateLinkServiceConnectionState', 'type': 'ConnectionState'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "private_endpoint": {"key": "properties.privateEndpoint", "type": "PrivateEndpoint"}, + "private_link_service_connection_state": { + "key": "properties.privateLinkServiceConnectionState", + "type": "ConnectionState", + }, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, } def __init__( @@ -1340,35 +1273,35 @@ def __init__( ): """ :keyword private_endpoint: The Private Endpoint resource for this Connection. - :paramtype private_endpoint: ~azure.mgmt.servicebus.v2022_01_01_preview.models.PrivateEndpoint + :paramtype private_endpoint: ~azure.mgmt.servicebus.v2022_01_10_preview.models.PrivateEndpoint :keyword private_link_service_connection_state: Details about the state of the connection. :paramtype private_link_service_connection_state: - ~azure.mgmt.servicebus.v2022_01_01_preview.models.ConnectionState + ~azure.mgmt.servicebus.v2022_01_10_preview.models.ConnectionState :keyword provisioning_state: Provisioning state of the Private Endpoint Connection. Known - values are: "Creating", "Updating", "Deleting", "Succeeded", "Canceled", "Failed". + values are: "Creating", "Updating", "Deleting", "Succeeded", "Canceled", and "Failed". :paramtype provisioning_state: str or - ~azure.mgmt.servicebus.v2022_01_01_preview.models.EndPointProvisioningState + ~azure.mgmt.servicebus.v2022_01_10_preview.models.EndPointProvisioningState """ - super(PrivateEndpointConnection, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.private_endpoint = private_endpoint self.private_link_service_connection_state = private_link_service_connection_state self.provisioning_state = provisioning_state -class PrivateEndpointConnectionListResult(msrest.serialization.Model): +class PrivateEndpointConnectionListResult(_serialization.Model): """Result of the list of all private endpoint connections operation. :ivar value: A collection of private endpoint connection resources. :vartype value: - list[~azure.mgmt.servicebus.v2022_01_01_preview.models.PrivateEndpointConnection] + list[~azure.mgmt.servicebus.v2022_01_10_preview.models.PrivateEndpointConnection] :ivar next_link: A link for the next page of private endpoint connection resources. :vartype next_link: str """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PrivateEndpointConnection]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[PrivateEndpointConnection]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( @@ -1381,16 +1314,16 @@ def __init__( """ :keyword value: A collection of private endpoint connection resources. :paramtype value: - list[~azure.mgmt.servicebus.v2022_01_01_preview.models.PrivateEndpointConnection] + list[~azure.mgmt.servicebus.v2022_01_10_preview.models.PrivateEndpointConnection] :keyword next_link: A link for the next page of private endpoint connection resources. :paramtype next_link: str """ - super(PrivateEndpointConnectionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class PrivateLinkResource(msrest.serialization.Model): +class PrivateLinkResource(_serialization.Model): """Information of the private link resource. :ivar id: Fully qualified identifier of the resource. @@ -1408,18 +1341,18 @@ class PrivateLinkResource(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'group_id': {'key': 'properties.groupId', 'type': 'str'}, - 'required_members': {'key': 'properties.requiredMembers', 'type': '[str]'}, - 'required_zone_names': {'key': 'properties.requiredZoneNames', 'type': '[str]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "group_id": {"key": "properties.groupId", "type": "str"}, + "required_members": {"key": "properties.requiredMembers", "type": "[str]"}, + "required_zone_names": {"key": "properties.requiredZoneNames", "type": "[str]"}, } def __init__( self, *, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin name: Optional[str] = None, type: Optional[str] = None, group_id: Optional[str] = None, @@ -1441,7 +1374,7 @@ def __init__( :keyword required_zone_names: Required Zone Names. :paramtype required_zone_names: list[str] """ - super(PrivateLinkResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.name = name self.type = type @@ -1450,81 +1383,71 @@ def __init__( self.required_zone_names = required_zone_names -class PrivateLinkResourcesListResult(msrest.serialization.Model): +class PrivateLinkResourcesListResult(_serialization.Model): """Result of the List private link resources operation. :ivar value: A collection of private link resources. - :vartype value: list[~azure.mgmt.servicebus.v2022_01_01_preview.models.PrivateLinkResource] + :vartype value: list[~azure.mgmt.servicebus.v2022_01_10_preview.models.PrivateLinkResource] :ivar next_link: A link for the next page of private link resources. :vartype next_link: str """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PrivateLinkResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[PrivateLinkResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["_models.PrivateLinkResource"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.PrivateLinkResource"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: A collection of private link resources. - :paramtype value: list[~azure.mgmt.servicebus.v2022_01_01_preview.models.PrivateLinkResource] + :paramtype value: list[~azure.mgmt.servicebus.v2022_01_10_preview.models.PrivateLinkResource] :keyword next_link: A link for the next page of private link resources. :paramtype next_link: str """ - super(PrivateLinkResourcesListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class RegenerateAccessKeyParameters(msrest.serialization.Model): +class RegenerateAccessKeyParameters(_serialization.Model): """Parameters supplied to the Regenerate Authorization Rule operation, specifies which key needs to be reset. All required parameters must be populated in order to send to Azure. - :ivar key_type: Required. The access key to regenerate. Known values are: "PrimaryKey", + :ivar key_type: The access key to regenerate. Required. Known values are: "PrimaryKey" and "SecondaryKey". - :vartype key_type: str or ~azure.mgmt.servicebus.v2022_01_01_preview.models.KeyType + :vartype key_type: str or ~azure.mgmt.servicebus.v2022_01_10_preview.models.KeyType :ivar key: Optional, if the key value provided, is reset for KeyType value or autogenerate Key value set for keyType. :vartype key: str """ _validation = { - 'key_type': {'required': True}, + "key_type": {"required": True}, } _attribute_map = { - 'key_type': {'key': 'keyType', 'type': 'str'}, - 'key': {'key': 'key', 'type': 'str'}, + "key_type": {"key": "keyType", "type": "str"}, + "key": {"key": "key", "type": "str"}, } - def __init__( - self, - *, - key_type: Union[str, "_models.KeyType"], - key: Optional[str] = None, - **kwargs - ): + def __init__(self, *, key_type: Union[str, "_models.KeyType"], key: Optional[str] = None, **kwargs): """ - :keyword key_type: Required. The access key to regenerate. Known values are: "PrimaryKey", + :keyword key_type: The access key to regenerate. Required. Known values are: "PrimaryKey" and "SecondaryKey". - :paramtype key_type: str or ~azure.mgmt.servicebus.v2022_01_01_preview.models.KeyType + :paramtype key_type: str or ~azure.mgmt.servicebus.v2022_01_10_preview.models.KeyType :keyword key: Optional, if the key value provided, is reset for KeyType value or autogenerate Key value set for keyType. :paramtype key: str """ - super(RegenerateAccessKeyParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_type = key_type self.key = key -class Resource(msrest.serialization.Model): +class Resource(_serialization.Model): """The Resource definition for other than namespace. Variables are only populated by the server, and will be ignored when sending a request. @@ -1538,24 +1461,20 @@ class Resource(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(Resource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -1574,38 +1493,32 @@ class ResourceNamespacePatch(Resource): :vartype type: str :ivar location: Resource location. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"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}'}, + "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: Optional[str] = None, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, **kwargs): """ :keyword location: Resource location. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] """ - super(ResourceNamespacePatch, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.tags = tags @@ -1626,38 +1539,38 @@ class Rule(ProxyResource): :ivar location: The geo-location where the resource lives. :vartype location: str :ivar system_data: The system meta data relating to this resource. - :vartype system_data: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SystemData + :vartype system_data: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SystemData :ivar action: Represents the filter actions which are allowed for the transformation of a message that have been matched by a filter expression. - :vartype action: ~azure.mgmt.servicebus.v2022_01_01_preview.models.Action + :vartype action: ~azure.mgmt.servicebus.v2022_01_10_preview.models.Action :ivar filter_type: Filter type that is evaluated against a BrokeredMessage. Known values are: - "SqlFilter", "CorrelationFilter". - :vartype filter_type: str or ~azure.mgmt.servicebus.v2022_01_01_preview.models.FilterType + "SqlFilter" and "CorrelationFilter". + :vartype filter_type: str or ~azure.mgmt.servicebus.v2022_01_10_preview.models.FilterType :ivar sql_filter: Properties of sqlFilter. - :vartype sql_filter: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SqlFilter + :vartype sql_filter: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SqlFilter :ivar correlation_filter: Properties of correlationFilter. :vartype correlation_filter: - ~azure.mgmt.servicebus.v2022_01_01_preview.models.CorrelationFilter + ~azure.mgmt.servicebus.v2022_01_10_preview.models.CorrelationFilter """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'readonly': True}, - 'system_data': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"readonly": 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'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'action': {'key': 'properties.action', 'type': 'Action'}, - 'filter_type': {'key': 'properties.filterType', 'type': 'str'}, - 'sql_filter': {'key': 'properties.sqlFilter', 'type': 'SqlFilter'}, - 'correlation_filter': {'key': 'properties.correlationFilter', 'type': 'CorrelationFilter'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "action": {"key": "properties.action", "type": "Action"}, + "filter_type": {"key": "properties.filterType", "type": "str"}, + "sql_filter": {"key": "properties.sqlFilter", "type": "SqlFilter"}, + "correlation_filter": {"key": "properties.correlationFilter", "type": "CorrelationFilter"}, } def __init__( @@ -1672,17 +1585,17 @@ def __init__( """ :keyword action: Represents the filter actions which are allowed for the transformation of a message that have been matched by a filter expression. - :paramtype action: ~azure.mgmt.servicebus.v2022_01_01_preview.models.Action + :paramtype action: ~azure.mgmt.servicebus.v2022_01_10_preview.models.Action :keyword filter_type: Filter type that is evaluated against a BrokeredMessage. Known values - are: "SqlFilter", "CorrelationFilter". - :paramtype filter_type: str or ~azure.mgmt.servicebus.v2022_01_01_preview.models.FilterType + are: "SqlFilter" and "CorrelationFilter". + :paramtype filter_type: str or ~azure.mgmt.servicebus.v2022_01_10_preview.models.FilterType :keyword sql_filter: Properties of sqlFilter. - :paramtype sql_filter: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SqlFilter + :paramtype sql_filter: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SqlFilter :keyword correlation_filter: Properties of correlationFilter. :paramtype correlation_filter: - ~azure.mgmt.servicebus.v2022_01_01_preview.models.CorrelationFilter + ~azure.mgmt.servicebus.v2022_01_10_preview.models.CorrelationFilter """ - super(Rule, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.action = action self.filter_type = filter_type @@ -1690,36 +1603,30 @@ def __init__( self.correlation_filter = correlation_filter -class RuleListResult(msrest.serialization.Model): +class RuleListResult(_serialization.Model): """The response of the List rule operation. :ivar value: Result of the List Rules operation. - :vartype value: list[~azure.mgmt.servicebus.v2022_01_01_preview.models.Rule] + :vartype value: list[~azure.mgmt.servicebus.v2022_01_10_preview.models.Rule] :ivar next_link: Link to the next set of results. Not empty if Value contains incomplete list of rules. :vartype next_link: str """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Rule]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Rule]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["_models.Rule"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Rule"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: Result of the List Rules operation. - :paramtype value: list[~azure.mgmt.servicebus.v2022_01_01_preview.models.Rule] + :paramtype value: list[~azure.mgmt.servicebus.v2022_01_10_preview.models.Rule] :keyword next_link: Link to the next set of results. Not empty if Value contains incomplete list of rules. :paramtype next_link: str """ - super(RuleListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link @@ -1740,78 +1647,69 @@ class SBAuthorizationRule(ProxyResource): :ivar location: The geo-location where the resource lives. :vartype location: str :ivar system_data: The system meta data relating to this resource. - :vartype system_data: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SystemData + :vartype system_data: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SystemData :ivar rights: The rights associated with the rule. - :vartype rights: list[str or ~azure.mgmt.servicebus.v2022_01_01_preview.models.AccessRights] + :vartype rights: list[str or ~azure.mgmt.servicebus.v2022_01_10_preview.models.AccessRights] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'readonly': True}, - 'system_data': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"readonly": 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'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'rights': {'key': 'properties.rights', 'type': '[str]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "rights": {"key": "properties.rights", "type": "[str]"}, } - def __init__( - self, - *, - rights: Optional[List[Union[str, "_models.AccessRights"]]] = None, - **kwargs - ): + def __init__(self, *, rights: Optional[List[Union[str, "_models.AccessRights"]]] = None, **kwargs): """ :keyword rights: The rights associated with the rule. - :paramtype rights: list[str or ~azure.mgmt.servicebus.v2022_01_01_preview.models.AccessRights] + :paramtype rights: list[str or ~azure.mgmt.servicebus.v2022_01_10_preview.models.AccessRights] """ - super(SBAuthorizationRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.rights = rights -class SBAuthorizationRuleListResult(msrest.serialization.Model): +class SBAuthorizationRuleListResult(_serialization.Model): """The response to the List Namespace operation. :ivar value: Result of the List Authorization Rules operation. - :vartype value: list[~azure.mgmt.servicebus.v2022_01_01_preview.models.SBAuthorizationRule] + :vartype value: list[~azure.mgmt.servicebus.v2022_01_10_preview.models.SBAuthorizationRule] :ivar next_link: Link to the next set of results. Not empty if Value contains incomplete list of Authorization Rules. :vartype next_link: str """ _attribute_map = { - 'value': {'key': 'value', 'type': '[SBAuthorizationRule]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SBAuthorizationRule]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["_models.SBAuthorizationRule"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.SBAuthorizationRule"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Result of the List Authorization Rules operation. - :paramtype value: list[~azure.mgmt.servicebus.v2022_01_01_preview.models.SBAuthorizationRule] + :paramtype value: list[~azure.mgmt.servicebus.v2022_01_10_preview.models.SBAuthorizationRule] :keyword next_link: Link to the next set of results. Not empty if Value contains incomplete list of Authorization Rules. :paramtype next_link: str """ - super(SBAuthorizationRuleListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class SBClientAffineProperties(msrest.serialization.Model): +class SBClientAffineProperties(_serialization.Model): """Properties specific to client affine subscriptions. :ivar client_id: Indicates the Client ID of the application that created the client-affine @@ -1826,9 +1724,9 @@ class SBClientAffineProperties(msrest.serialization.Model): """ _attribute_map = { - 'client_id': {'key': 'clientId', 'type': 'str'}, - 'is_durable': {'key': 'isDurable', 'type': 'bool'}, - 'is_shared': {'key': 'isShared', 'type': 'bool'}, + "client_id": {"key": "clientId", "type": "str"}, + "is_durable": {"key": "isDurable", "type": "bool"}, + "is_shared": {"key": "isShared", "type": "bool"}, } def __init__( @@ -1850,7 +1748,7 @@ def __init__( subscription is shared or not. :paramtype is_shared: bool """ - super(SBClientAffineProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.client_id = client_id self.is_durable = is_durable self.is_shared = is_shared @@ -1869,46 +1767,40 @@ class TrackedResource(Resource): :vartype name: str :ivar type: Resource type. :vartype type: str - :ivar location: Required. The Geo-location where the resource lives. + :ivar location: The Geo-location where the resource lives. Required. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "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 Geo-location where the resource lives. + :keyword location: The Geo-location where the resource lives. Required. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] """ - super(TrackedResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.tags = tags -class SBNamespace(TrackedResource): +class SBNamespace(TrackedResource): # pylint: disable=too-many-instance-attributes """Description of a namespace resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -1921,20 +1813,20 @@ class SBNamespace(TrackedResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :ivar location: Required. The Geo-location where the resource lives. + :ivar location: The Geo-location where the resource lives. Required. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar sku: Properties of SKU. - :vartype sku: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBSku + :vartype sku: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SBSku :ivar identity: Properties of BYOK Identity description. - :vartype identity: ~azure.mgmt.servicebus.v2022_01_01_preview.models.Identity + :vartype identity: ~azure.mgmt.servicebus.v2022_01_10_preview.models.Identity :ivar system_data: The system meta data relating to this resource. - :vartype system_data: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SystemData + :vartype system_data: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SystemData :ivar minimum_tls_version: The minimum TLS version for the cluster to support, e.g. '1.2'. - Known values are: "1.0", "1.1", "1.2". + Known values are: "1.0", "1.1", and "1.2". :vartype minimum_tls_version: str or - ~azure.mgmt.servicebus.v2022_01_01_preview.models.TlsVersion + ~azure.mgmt.servicebus.v2022_01_10_preview.models.TlsVersion :ivar provisioning_state: Provisioning state of the namespace. :vartype provisioning_state: str :ivar status: Status of the namespace. @@ -1951,58 +1843,60 @@ class SBNamespace(TrackedResource): supported availability zones. :vartype zone_redundant: bool :ivar encryption: Properties of BYOK Encryption description. - :vartype encryption: ~azure.mgmt.servicebus.v2022_01_01_preview.models.Encryption + :vartype encryption: ~azure.mgmt.servicebus.v2022_01_10_preview.models.Encryption :ivar private_endpoint_connections: List of private endpoint connections. :vartype private_endpoint_connections: - list[~azure.mgmt.servicebus.v2022_01_01_preview.models.PrivateEndpointConnection] + list[~azure.mgmt.servicebus.v2022_01_10_preview.models.PrivateEndpointConnection] :ivar disable_local_auth: This property disables SAS authentication for the Service Bus namespace. :vartype disable_local_auth: bool :ivar alternate_name: Alternate name for namespace. :vartype alternate_name: str :ivar public_network_access: This determines if traffic is allowed over public network. By - default it is enabled. Known values are: "Enabled", "Disabled", "SecuredByPerimeter". Default - value: "Enabled". + default it is enabled. Known values are: "Enabled", "Disabled", and "SecuredByPerimeter". :vartype public_network_access: str or - ~azure.mgmt.servicebus.v2022_01_01_preview.models.PublicNetworkAccess + ~azure.mgmt.servicebus.v2022_01_10_preview.models.PublicNetworkAccess """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'status': {'readonly': True}, - 'created_at': {'readonly': True}, - 'updated_at': {'readonly': True}, - 'service_bus_endpoint': {'readonly': True}, - 'metric_id': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "system_data": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "status": {"readonly": True}, + "created_at": {"readonly": True}, + "updated_at": {"readonly": True}, + "service_bus_endpoint": {"readonly": True}, + "metric_id": {"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}'}, - 'sku': {'key': 'sku', 'type': 'SBSku'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'minimum_tls_version': {'key': 'properties.minimumTlsVersion', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'created_at': {'key': 'properties.createdAt', 'type': 'iso-8601'}, - 'updated_at': {'key': 'properties.updatedAt', 'type': 'iso-8601'}, - 'service_bus_endpoint': {'key': 'properties.serviceBusEndpoint', 'type': 'str'}, - 'metric_id': {'key': 'properties.metricId', 'type': 'str'}, - 'zone_redundant': {'key': 'properties.zoneRedundant', 'type': 'bool'}, - 'encryption': {'key': 'properties.encryption', 'type': 'Encryption'}, - 'private_endpoint_connections': {'key': 'properties.privateEndpointConnections', 'type': '[PrivateEndpointConnection]'}, - 'disable_local_auth': {'key': 'properties.disableLocalAuth', 'type': 'bool'}, - 'alternate_name': {'key': 'properties.alternateName', 'type': 'str'}, - 'public_network_access': {'key': 'properties.publicNetworkAccess', '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}"}, + "sku": {"key": "sku", "type": "SBSku"}, + "identity": {"key": "identity", "type": "Identity"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "minimum_tls_version": {"key": "properties.minimumTlsVersion", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "status": {"key": "properties.status", "type": "str"}, + "created_at": {"key": "properties.createdAt", "type": "iso-8601"}, + "updated_at": {"key": "properties.updatedAt", "type": "iso-8601"}, + "service_bus_endpoint": {"key": "properties.serviceBusEndpoint", "type": "str"}, + "metric_id": {"key": "properties.metricId", "type": "str"}, + "zone_redundant": {"key": "properties.zoneRedundant", "type": "bool"}, + "encryption": {"key": "properties.encryption", "type": "Encryption"}, + "private_endpoint_connections": { + "key": "properties.privateEndpointConnections", + "type": "[PrivateEndpointConnection]", + }, + "disable_local_auth": {"key": "properties.disableLocalAuth", "type": "bool"}, + "alternate_name": {"key": "properties.alternateName", "type": "str"}, + "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, } def __init__( @@ -2018,42 +1912,41 @@ def __init__( private_endpoint_connections: Optional[List["_models.PrivateEndpointConnection"]] = None, disable_local_auth: Optional[bool] = None, alternate_name: Optional[str] = None, - public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = "Enabled", + public_network_access: Union[str, "_models.PublicNetworkAccess"] = "Enabled", **kwargs ): """ - :keyword location: Required. The Geo-location where the resource lives. + :keyword location: The Geo-location where the resource lives. Required. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword sku: Properties of SKU. - :paramtype sku: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBSku + :paramtype sku: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SBSku :keyword identity: Properties of BYOK Identity description. - :paramtype identity: ~azure.mgmt.servicebus.v2022_01_01_preview.models.Identity + :paramtype identity: ~azure.mgmt.servicebus.v2022_01_10_preview.models.Identity :keyword minimum_tls_version: The minimum TLS version for the cluster to support, e.g. '1.2'. - Known values are: "1.0", "1.1", "1.2". + Known values are: "1.0", "1.1", and "1.2". :paramtype minimum_tls_version: str or - ~azure.mgmt.servicebus.v2022_01_01_preview.models.TlsVersion + ~azure.mgmt.servicebus.v2022_01_10_preview.models.TlsVersion :keyword zone_redundant: Enabling this property creates a Premium Service Bus Namespace in regions supported availability zones. :paramtype zone_redundant: bool :keyword encryption: Properties of BYOK Encryption description. - :paramtype encryption: ~azure.mgmt.servicebus.v2022_01_01_preview.models.Encryption + :paramtype encryption: ~azure.mgmt.servicebus.v2022_01_10_preview.models.Encryption :keyword private_endpoint_connections: List of private endpoint connections. :paramtype private_endpoint_connections: - list[~azure.mgmt.servicebus.v2022_01_01_preview.models.PrivateEndpointConnection] + list[~azure.mgmt.servicebus.v2022_01_10_preview.models.PrivateEndpointConnection] :keyword disable_local_auth: This property disables SAS authentication for the Service Bus namespace. :paramtype disable_local_auth: bool :keyword alternate_name: Alternate name for namespace. :paramtype alternate_name: str :keyword public_network_access: This determines if traffic is allowed over public network. By - default it is enabled. Known values are: "Enabled", "Disabled", "SecuredByPerimeter". Default - value: "Enabled". + default it is enabled. Known values are: "Enabled", "Disabled", and "SecuredByPerimeter". :paramtype public_network_access: str or - ~azure.mgmt.servicebus.v2022_01_01_preview.models.PublicNetworkAccess + ~azure.mgmt.servicebus.v2022_01_10_preview.models.PublicNetworkAccess """ - super(SBNamespace, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.sku = sku self.identity = identity self.system_data = None @@ -2072,41 +1965,37 @@ def __init__( self.public_network_access = public_network_access -class SBNamespaceListResult(msrest.serialization.Model): +class SBNamespaceListResult(_serialization.Model): """The response of the List Namespace operation. :ivar value: Result of the List Namespace operation. - :vartype value: list[~azure.mgmt.servicebus.v2022_01_01_preview.models.SBNamespace] + :vartype value: list[~azure.mgmt.servicebus.v2022_01_10_preview.models.SBNamespace] :ivar next_link: Link to the next set of results. Not empty if Value contains incomplete list of Namespaces. :vartype next_link: str """ _attribute_map = { - 'value': {'key': 'value', 'type': '[SBNamespace]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SBNamespace]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["_models.SBNamespace"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.SBNamespace"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Result of the List Namespace operation. - :paramtype value: list[~azure.mgmt.servicebus.v2022_01_01_preview.models.SBNamespace] + :paramtype value: list[~azure.mgmt.servicebus.v2022_01_10_preview.models.SBNamespace] :keyword next_link: Link to the next set of results. Not empty if Value contains incomplete list of Namespaces. :paramtype next_link: str """ - super(SBNamespaceListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class SBNamespaceUpdateParameters(ResourceNamespacePatch): +class SBNamespaceUpdateParameters(ResourceNamespacePatch): # pylint: disable=too-many-instance-attributes """Description of a namespace resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -2119,12 +2008,12 @@ class SBNamespaceUpdateParameters(ResourceNamespacePatch): :vartype type: str :ivar location: Resource location. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar sku: Properties of SKU. - :vartype sku: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBSku + :vartype sku: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SBSku :ivar identity: Properties of BYOK Identity description. - :vartype identity: ~azure.mgmt.servicebus.v2022_01_01_preview.models.Identity + :vartype identity: ~azure.mgmt.servicebus.v2022_01_10_preview.models.Identity :ivar provisioning_state: Provisioning state of the namespace. :vartype provisioning_state: str :ivar status: Status of the namespace. @@ -2138,10 +2027,10 @@ class SBNamespaceUpdateParameters(ResourceNamespacePatch): :ivar metric_id: Identifier for Azure Insights metrics. :vartype metric_id: str :ivar encryption: Properties of BYOK Encryption description. - :vartype encryption: ~azure.mgmt.servicebus.v2022_01_01_preview.models.Encryption + :vartype encryption: ~azure.mgmt.servicebus.v2022_01_10_preview.models.Encryption :ivar private_endpoint_connections: List of private endpoint connections. :vartype private_endpoint_connections: - list[~azure.mgmt.servicebus.v2022_01_01_preview.models.PrivateEndpointConnection] + list[~azure.mgmt.servicebus.v2022_01_10_preview.models.PrivateEndpointConnection] :ivar disable_local_auth: This property disables SAS authentication for the Service Bus namespace. :vartype disable_local_auth: bool @@ -2150,35 +2039,38 @@ class SBNamespaceUpdateParameters(ResourceNamespacePatch): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'status': {'readonly': True}, - 'created_at': {'readonly': True}, - 'updated_at': {'readonly': True}, - 'service_bus_endpoint': {'readonly': True}, - 'metric_id': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "status": {"readonly": True}, + "created_at": {"readonly": True}, + "updated_at": {"readonly": True}, + "service_bus_endpoint": {"readonly": True}, + "metric_id": {"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}'}, - 'sku': {'key': 'sku', 'type': 'SBSku'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'created_at': {'key': 'properties.createdAt', 'type': 'iso-8601'}, - 'updated_at': {'key': 'properties.updatedAt', 'type': 'iso-8601'}, - 'service_bus_endpoint': {'key': 'properties.serviceBusEndpoint', 'type': 'str'}, - 'metric_id': {'key': 'properties.metricId', 'type': 'str'}, - 'encryption': {'key': 'properties.encryption', 'type': 'Encryption'}, - 'private_endpoint_connections': {'key': 'properties.privateEndpointConnections', 'type': '[PrivateEndpointConnection]'}, - 'disable_local_auth': {'key': 'properties.disableLocalAuth', 'type': 'bool'}, - 'alternate_name': {'key': 'properties.alternateName', '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}"}, + "sku": {"key": "sku", "type": "SBSku"}, + "identity": {"key": "identity", "type": "Identity"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "status": {"key": "properties.status", "type": "str"}, + "created_at": {"key": "properties.createdAt", "type": "iso-8601"}, + "updated_at": {"key": "properties.updatedAt", "type": "iso-8601"}, + "service_bus_endpoint": {"key": "properties.serviceBusEndpoint", "type": "str"}, + "metric_id": {"key": "properties.metricId", "type": "str"}, + "encryption": {"key": "properties.encryption", "type": "Encryption"}, + "private_endpoint_connections": { + "key": "properties.privateEndpointConnections", + "type": "[PrivateEndpointConnection]", + }, + "disable_local_auth": {"key": "properties.disableLocalAuth", "type": "bool"}, + "alternate_name": {"key": "properties.alternateName", "type": "str"}, } def __init__( @@ -2197,24 +2089,24 @@ def __init__( """ :keyword location: Resource location. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword sku: Properties of SKU. - :paramtype sku: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBSku + :paramtype sku: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SBSku :keyword identity: Properties of BYOK Identity description. - :paramtype identity: ~azure.mgmt.servicebus.v2022_01_01_preview.models.Identity + :paramtype identity: ~azure.mgmt.servicebus.v2022_01_10_preview.models.Identity :keyword encryption: Properties of BYOK Encryption description. - :paramtype encryption: ~azure.mgmt.servicebus.v2022_01_01_preview.models.Encryption + :paramtype encryption: ~azure.mgmt.servicebus.v2022_01_10_preview.models.Encryption :keyword private_endpoint_connections: List of private endpoint connections. :paramtype private_endpoint_connections: - list[~azure.mgmt.servicebus.v2022_01_01_preview.models.PrivateEndpointConnection] + list[~azure.mgmt.servicebus.v2022_01_10_preview.models.PrivateEndpointConnection] :keyword disable_local_auth: This property disables SAS authentication for the Service Bus namespace. :paramtype disable_local_auth: bool :keyword alternate_name: Alternate name for namespace. :paramtype alternate_name: str """ - super(SBNamespaceUpdateParameters, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.sku = sku self.identity = identity self.provisioning_state = None @@ -2229,7 +2121,7 @@ def __init__( self.alternate_name = alternate_name -class SBQueue(ProxyResource): +class SBQueue(ProxyResource): # pylint: disable=too-many-instance-attributes """Description of queue Resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -2245,9 +2137,9 @@ class SBQueue(ProxyResource): :ivar location: The geo-location where the resource lives. :vartype location: str :ivar system_data: The system meta data relating to this resource. - :vartype system_data: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SystemData + :vartype system_data: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SystemData :ivar count_details: Message Count Details. - :vartype count_details: ~azure.mgmt.servicebus.v2022_01_01_preview.models.MessageCountDetails + :vartype count_details: ~azure.mgmt.servicebus.v2022_01_10_preview.models.MessageCountDetails :ivar created_at: The exact time the message was created. :vartype created_at: ~datetime.datetime :ivar updated_at: The exact time the message was updated. @@ -2256,9 +2148,9 @@ class SBQueue(ProxyResource): to this queue. :vartype accessed_at: ~datetime.datetime :ivar size_in_bytes: The size of the queue, in bytes. - :vartype size_in_bytes: long + :vartype size_in_bytes: int :ivar message_count: The number of messages in the queue. - :vartype message_count: long + :vartype message_count: int :ivar lock_duration: ISO 8601 timespan duration of a peek-lock; that is, the amount of time that the message is locked for other receivers. The maximum value for LockDuration is 5 minutes; the default value is 1 minute. @@ -2268,7 +2160,7 @@ class SBQueue(ProxyResource): :vartype max_size_in_megabytes: int :ivar max_message_size_in_kilobytes: Maximum size (in KB) of the message payload that can be accepted by the queue. This property is only used in Premium today and default is 1024. - :vartype max_message_size_in_kilobytes: long + :vartype max_message_size_in_kilobytes: int :ivar requires_duplicate_detection: A value indicating if this queue requires duplicate detection. :vartype requires_duplicate_detection: bool @@ -2290,8 +2182,8 @@ class SBQueue(ProxyResource): :vartype max_delivery_count: int :ivar status: Enumerates the possible values for the status of a messaging entity. Known values are: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", "Creating", - "Deleting", "Renaming", "Unknown". - :vartype status: str or ~azure.mgmt.servicebus.v2022_01_01_preview.models.EntityStatus + "Deleting", "Renaming", and "Unknown". + :vartype status: str or ~azure.mgmt.servicebus.v2022_01_10_preview.models.EntityStatus :ivar enable_batched_operations: Value that indicates whether server-side batched operations are enabled. :vartype enable_batched_operations: bool @@ -2311,50 +2203,53 @@ class SBQueue(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'readonly': True}, - 'system_data': {'readonly': True}, - 'count_details': {'readonly': True}, - 'created_at': {'readonly': True}, - 'updated_at': {'readonly': True}, - 'accessed_at': {'readonly': True}, - 'size_in_bytes': {'readonly': True}, - 'message_count': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"readonly": True}, + "system_data": {"readonly": True}, + "count_details": {"readonly": True}, + "created_at": {"readonly": True}, + "updated_at": {"readonly": True}, + "accessed_at": {"readonly": True}, + "size_in_bytes": {"readonly": True}, + "message_count": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'count_details': {'key': 'properties.countDetails', 'type': 'MessageCountDetails'}, - 'created_at': {'key': 'properties.createdAt', 'type': 'iso-8601'}, - 'updated_at': {'key': 'properties.updatedAt', 'type': 'iso-8601'}, - 'accessed_at': {'key': 'properties.accessedAt', 'type': 'iso-8601'}, - 'size_in_bytes': {'key': 'properties.sizeInBytes', 'type': 'long'}, - 'message_count': {'key': 'properties.messageCount', 'type': 'long'}, - 'lock_duration': {'key': 'properties.lockDuration', 'type': 'duration'}, - 'max_size_in_megabytes': {'key': 'properties.maxSizeInMegabytes', 'type': 'int'}, - 'max_message_size_in_kilobytes': {'key': 'properties.maxMessageSizeInKilobytes', 'type': 'long'}, - 'requires_duplicate_detection': {'key': 'properties.requiresDuplicateDetection', 'type': 'bool'}, - 'requires_session': {'key': 'properties.requiresSession', 'type': 'bool'}, - 'default_message_time_to_live': {'key': 'properties.defaultMessageTimeToLive', 'type': 'duration'}, - 'dead_lettering_on_message_expiration': {'key': 'properties.deadLetteringOnMessageExpiration', 'type': 'bool'}, - 'duplicate_detection_history_time_window': {'key': 'properties.duplicateDetectionHistoryTimeWindow', 'type': 'duration'}, - 'max_delivery_count': {'key': 'properties.maxDeliveryCount', 'type': 'int'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'enable_batched_operations': {'key': 'properties.enableBatchedOperations', 'type': 'bool'}, - 'auto_delete_on_idle': {'key': 'properties.autoDeleteOnIdle', 'type': 'duration'}, - 'enable_partitioning': {'key': 'properties.enablePartitioning', 'type': 'bool'}, - 'enable_express': {'key': 'properties.enableExpress', 'type': 'bool'}, - 'forward_to': {'key': 'properties.forwardTo', 'type': 'str'}, - 'forward_dead_lettered_messages_to': {'key': 'properties.forwardDeadLetteredMessagesTo', 'type': 'str'}, - } - - def __init__( + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "count_details": {"key": "properties.countDetails", "type": "MessageCountDetails"}, + "created_at": {"key": "properties.createdAt", "type": "iso-8601"}, + "updated_at": {"key": "properties.updatedAt", "type": "iso-8601"}, + "accessed_at": {"key": "properties.accessedAt", "type": "iso-8601"}, + "size_in_bytes": {"key": "properties.sizeInBytes", "type": "int"}, + "message_count": {"key": "properties.messageCount", "type": "int"}, + "lock_duration": {"key": "properties.lockDuration", "type": "duration"}, + "max_size_in_megabytes": {"key": "properties.maxSizeInMegabytes", "type": "int"}, + "max_message_size_in_kilobytes": {"key": "properties.maxMessageSizeInKilobytes", "type": "int"}, + "requires_duplicate_detection": {"key": "properties.requiresDuplicateDetection", "type": "bool"}, + "requires_session": {"key": "properties.requiresSession", "type": "bool"}, + "default_message_time_to_live": {"key": "properties.defaultMessageTimeToLive", "type": "duration"}, + "dead_lettering_on_message_expiration": {"key": "properties.deadLetteringOnMessageExpiration", "type": "bool"}, + "duplicate_detection_history_time_window": { + "key": "properties.duplicateDetectionHistoryTimeWindow", + "type": "duration", + }, + "max_delivery_count": {"key": "properties.maxDeliveryCount", "type": "int"}, + "status": {"key": "properties.status", "type": "str"}, + "enable_batched_operations": {"key": "properties.enableBatchedOperations", "type": "bool"}, + "auto_delete_on_idle": {"key": "properties.autoDeleteOnIdle", "type": "duration"}, + "enable_partitioning": {"key": "properties.enablePartitioning", "type": "bool"}, + "enable_express": {"key": "properties.enableExpress", "type": "bool"}, + "forward_to": {"key": "properties.forwardTo", "type": "str"}, + "forward_dead_lettered_messages_to": {"key": "properties.forwardDeadLetteredMessagesTo", "type": "str"}, + } + + def __init__( # pylint: disable=too-many-locals self, *, lock_duration: Optional[datetime.timedelta] = None, @@ -2385,7 +2280,7 @@ def __init__( :paramtype max_size_in_megabytes: int :keyword max_message_size_in_kilobytes: Maximum size (in KB) of the message payload that can be accepted by the queue. This property is only used in Premium today and default is 1024. - :paramtype max_message_size_in_kilobytes: long + :paramtype max_message_size_in_kilobytes: int :keyword requires_duplicate_detection: A value indicating if this queue requires duplicate detection. :paramtype requires_duplicate_detection: bool @@ -2407,8 +2302,8 @@ def __init__( :paramtype max_delivery_count: int :keyword status: Enumerates the possible values for the status of a messaging entity. Known values are: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", "Creating", - "Deleting", "Renaming", "Unknown". - :paramtype status: str or ~azure.mgmt.servicebus.v2022_01_01_preview.models.EntityStatus + "Deleting", "Renaming", and "Unknown". + :paramtype status: str or ~azure.mgmt.servicebus.v2022_01_10_preview.models.EntityStatus :keyword enable_batched_operations: Value that indicates whether server-side batched operations are enabled. :paramtype enable_batched_operations: bool @@ -2427,7 +2322,7 @@ def __init__( message. :paramtype forward_dead_lettered_messages_to: str """ - super(SBQueue, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.count_details = None self.created_at = None @@ -2453,63 +2348,57 @@ def __init__( self.forward_dead_lettered_messages_to = forward_dead_lettered_messages_to -class SBQueueListResult(msrest.serialization.Model): +class SBQueueListResult(_serialization.Model): """The response to the List Queues operation. :ivar value: Result of the List Queues operation. - :vartype value: list[~azure.mgmt.servicebus.v2022_01_01_preview.models.SBQueue] + :vartype value: list[~azure.mgmt.servicebus.v2022_01_10_preview.models.SBQueue] :ivar next_link: Link to the next set of results. Not empty if Value contains incomplete list of queues. :vartype next_link: str """ _attribute_map = { - 'value': {'key': 'value', 'type': '[SBQueue]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SBQueue]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["_models.SBQueue"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.SBQueue"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: Result of the List Queues operation. - :paramtype value: list[~azure.mgmt.servicebus.v2022_01_01_preview.models.SBQueue] + :paramtype value: list[~azure.mgmt.servicebus.v2022_01_10_preview.models.SBQueue] :keyword next_link: Link to the next set of results. Not empty if Value contains incomplete list of queues. :paramtype next_link: str """ - super(SBQueueListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class SBSku(msrest.serialization.Model): +class SBSku(_serialization.Model): """SKU of the namespace. All required parameters must be populated in order to send to Azure. - :ivar name: Required. Name of this SKU. Known values are: "Basic", "Standard", "Premium". - :vartype name: str or ~azure.mgmt.servicebus.v2022_01_01_preview.models.SkuName - :ivar tier: The billing tier of this particular SKU. Known values are: "Basic", "Standard", + :ivar name: Name of this SKU. Required. Known values are: "Basic", "Standard", and "Premium". + :vartype name: str or ~azure.mgmt.servicebus.v2022_01_10_preview.models.SkuName + :ivar tier: The billing tier of this particular SKU. Known values are: "Basic", "Standard", and "Premium". - :vartype tier: str or ~azure.mgmt.servicebus.v2022_01_01_preview.models.SkuTier + :vartype tier: str or ~azure.mgmt.servicebus.v2022_01_10_preview.models.SkuTier :ivar capacity: The specified messaging units for the tier. For Premium tier, capacity are 1,2 and 4. :vartype capacity: int """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'capacity': {'key': 'capacity', 'type': 'int'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "capacity": {"key": "capacity", "type": "int"}, } def __init__( @@ -2521,22 +2410,23 @@ def __init__( **kwargs ): """ - :keyword name: Required. Name of this SKU. Known values are: "Basic", "Standard", "Premium". - :paramtype name: str or ~azure.mgmt.servicebus.v2022_01_01_preview.models.SkuName - :keyword tier: The billing tier of this particular SKU. Known values are: "Basic", "Standard", + :keyword name: Name of this SKU. Required. Known values are: "Basic", "Standard", and "Premium". - :paramtype tier: str or ~azure.mgmt.servicebus.v2022_01_01_preview.models.SkuTier + :paramtype name: str or ~azure.mgmt.servicebus.v2022_01_10_preview.models.SkuName + :keyword tier: The billing tier of this particular SKU. Known values are: "Basic", "Standard", + and "Premium". + :paramtype tier: str or ~azure.mgmt.servicebus.v2022_01_10_preview.models.SkuTier :keyword capacity: The specified messaging units for the tier. For Premium tier, capacity are 1,2 and 4. :paramtype capacity: int """ - super(SBSku, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.tier = tier self.capacity = capacity -class SBSubscription(ProxyResource): +class SBSubscription(ProxyResource): # pylint: disable=too-many-instance-attributes """Description of subscription resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -2552,9 +2442,9 @@ class SBSubscription(ProxyResource): :ivar location: The geo-location where the resource lives. :vartype location: str :ivar system_data: The system meta data relating to this resource. - :vartype system_data: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SystemData + :vartype system_data: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SystemData :ivar message_count: Number of messages. - :vartype message_count: long + :vartype message_count: int :ivar created_at: Exact time the message was created. :vartype created_at: ~datetime.datetime :ivar accessed_at: Last time there was a receive request to this subscription. @@ -2562,7 +2452,7 @@ class SBSubscription(ProxyResource): :ivar updated_at: The exact time the message was updated. :vartype updated_at: ~datetime.datetime :ivar count_details: Message count details. - :vartype count_details: ~azure.mgmt.servicebus.v2022_01_01_preview.models.MessageCountDetails + :vartype count_details: ~azure.mgmt.servicebus.v2022_01_10_preview.models.MessageCountDetails :ivar lock_duration: ISO 8061 lock duration timespan for the subscription. The default value is 1 minute. :vartype lock_duration: ~datetime.timedelta @@ -2585,8 +2475,8 @@ class SBSubscription(ProxyResource): :vartype max_delivery_count: int :ivar status: Enumerates the possible values for the status of a messaging entity. Known values are: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", "Creating", - "Deleting", "Renaming", "Unknown". - :vartype status: str or ~azure.mgmt.servicebus.v2022_01_01_preview.models.EntityStatus + "Deleting", "Renaming", and "Unknown". + :vartype status: str or ~azure.mgmt.servicebus.v2022_01_10_preview.models.EntityStatus :ivar enable_batched_operations: Value that indicates whether server-side batched operations are enabled. :vartype enable_batched_operations: bool @@ -2602,50 +2492,56 @@ class SBSubscription(ProxyResource): :vartype is_client_affine: bool :ivar client_affine_properties: Properties specific to client affine subscriptions. :vartype client_affine_properties: - ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBClientAffineProperties + ~azure.mgmt.servicebus.v2022_01_10_preview.models.SBClientAffineProperties """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'readonly': True}, - 'system_data': {'readonly': True}, - 'message_count': {'readonly': True}, - 'created_at': {'readonly': True}, - 'accessed_at': {'readonly': True}, - 'updated_at': {'readonly': True}, - 'count_details': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"readonly": True}, + "system_data": {"readonly": True}, + "message_count": {"readonly": True}, + "created_at": {"readonly": True}, + "accessed_at": {"readonly": True}, + "updated_at": {"readonly": True}, + "count_details": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'message_count': {'key': 'properties.messageCount', 'type': 'long'}, - 'created_at': {'key': 'properties.createdAt', 'type': 'iso-8601'}, - 'accessed_at': {'key': 'properties.accessedAt', 'type': 'iso-8601'}, - 'updated_at': {'key': 'properties.updatedAt', 'type': 'iso-8601'}, - 'count_details': {'key': 'properties.countDetails', 'type': 'MessageCountDetails'}, - 'lock_duration': {'key': 'properties.lockDuration', 'type': 'duration'}, - 'requires_session': {'key': 'properties.requiresSession', 'type': 'bool'}, - 'default_message_time_to_live': {'key': 'properties.defaultMessageTimeToLive', 'type': 'duration'}, - 'dead_lettering_on_filter_evaluation_exceptions': {'key': 'properties.deadLetteringOnFilterEvaluationExceptions', 'type': 'bool'}, - 'dead_lettering_on_message_expiration': {'key': 'properties.deadLetteringOnMessageExpiration', 'type': 'bool'}, - 'duplicate_detection_history_time_window': {'key': 'properties.duplicateDetectionHistoryTimeWindow', 'type': 'duration'}, - 'max_delivery_count': {'key': 'properties.maxDeliveryCount', 'type': 'int'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'enable_batched_operations': {'key': 'properties.enableBatchedOperations', 'type': 'bool'}, - 'auto_delete_on_idle': {'key': 'properties.autoDeleteOnIdle', 'type': 'duration'}, - 'forward_to': {'key': 'properties.forwardTo', 'type': 'str'}, - 'forward_dead_lettered_messages_to': {'key': 'properties.forwardDeadLetteredMessagesTo', 'type': 'str'}, - 'is_client_affine': {'key': 'properties.isClientAffine', 'type': 'bool'}, - 'client_affine_properties': {'key': 'properties.clientAffineProperties', 'type': 'SBClientAffineProperties'}, - } - - def __init__( + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "message_count": {"key": "properties.messageCount", "type": "int"}, + "created_at": {"key": "properties.createdAt", "type": "iso-8601"}, + "accessed_at": {"key": "properties.accessedAt", "type": "iso-8601"}, + "updated_at": {"key": "properties.updatedAt", "type": "iso-8601"}, + "count_details": {"key": "properties.countDetails", "type": "MessageCountDetails"}, + "lock_duration": {"key": "properties.lockDuration", "type": "duration"}, + "requires_session": {"key": "properties.requiresSession", "type": "bool"}, + "default_message_time_to_live": {"key": "properties.defaultMessageTimeToLive", "type": "duration"}, + "dead_lettering_on_filter_evaluation_exceptions": { + "key": "properties.deadLetteringOnFilterEvaluationExceptions", + "type": "bool", + }, + "dead_lettering_on_message_expiration": {"key": "properties.deadLetteringOnMessageExpiration", "type": "bool"}, + "duplicate_detection_history_time_window": { + "key": "properties.duplicateDetectionHistoryTimeWindow", + "type": "duration", + }, + "max_delivery_count": {"key": "properties.maxDeliveryCount", "type": "int"}, + "status": {"key": "properties.status", "type": "str"}, + "enable_batched_operations": {"key": "properties.enableBatchedOperations", "type": "bool"}, + "auto_delete_on_idle": {"key": "properties.autoDeleteOnIdle", "type": "duration"}, + "forward_to": {"key": "properties.forwardTo", "type": "str"}, + "forward_dead_lettered_messages_to": {"key": "properties.forwardDeadLetteredMessagesTo", "type": "str"}, + "is_client_affine": {"key": "properties.isClientAffine", "type": "bool"}, + "client_affine_properties": {"key": "properties.clientAffineProperties", "type": "SBClientAffineProperties"}, + } + + def __init__( # pylint: disable=too-many-locals self, *, lock_duration: Optional[datetime.timedelta] = None, @@ -2687,8 +2583,8 @@ def __init__( :paramtype max_delivery_count: int :keyword status: Enumerates the possible values for the status of a messaging entity. Known values are: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", "Creating", - "Deleting", "Renaming", "Unknown". - :paramtype status: str or ~azure.mgmt.servicebus.v2022_01_01_preview.models.EntityStatus + "Deleting", "Renaming", and "Unknown". + :paramtype status: str or ~azure.mgmt.servicebus.v2022_01_10_preview.models.EntityStatus :keyword enable_batched_operations: Value that indicates whether server-side batched operations are enabled. :paramtype enable_batched_operations: bool @@ -2705,9 +2601,9 @@ def __init__( :paramtype is_client_affine: bool :keyword client_affine_properties: Properties specific to client affine subscriptions. :paramtype client_affine_properties: - ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBClientAffineProperties + ~azure.mgmt.servicebus.v2022_01_10_preview.models.SBClientAffineProperties """ - super(SBSubscription, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.message_count = None self.created_at = None @@ -2730,41 +2626,37 @@ def __init__( self.client_affine_properties = client_affine_properties -class SBSubscriptionListResult(msrest.serialization.Model): +class SBSubscriptionListResult(_serialization.Model): """The response to the List Subscriptions operation. :ivar value: Result of the List Subscriptions operation. - :vartype value: list[~azure.mgmt.servicebus.v2022_01_01_preview.models.SBSubscription] + :vartype value: list[~azure.mgmt.servicebus.v2022_01_10_preview.models.SBSubscription] :ivar next_link: Link to the next set of results. Not empty if Value contains incomplete list of subscriptions. :vartype next_link: str """ _attribute_map = { - 'value': {'key': 'value', 'type': '[SBSubscription]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SBSubscription]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["_models.SBSubscription"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.SBSubscription"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Result of the List Subscriptions operation. - :paramtype value: list[~azure.mgmt.servicebus.v2022_01_01_preview.models.SBSubscription] + :paramtype value: list[~azure.mgmt.servicebus.v2022_01_10_preview.models.SBSubscription] :keyword next_link: Link to the next set of results. Not empty if Value contains incomplete list of subscriptions. :paramtype next_link: str """ - super(SBSubscriptionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class SBTopic(ProxyResource): +class SBTopic(ProxyResource): # pylint: disable=too-many-instance-attributes """Description of topic resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -2780,9 +2672,9 @@ class SBTopic(ProxyResource): :ivar location: The geo-location where the resource lives. :vartype location: str :ivar system_data: The system meta data relating to this resource. - :vartype system_data: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SystemData + :vartype system_data: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SystemData :ivar size_in_bytes: Size of the topic, in bytes. - :vartype size_in_bytes: long + :vartype size_in_bytes: int :ivar created_at: Exact time the message was created. :vartype created_at: ~datetime.datetime :ivar updated_at: The exact time the message was updated. @@ -2792,7 +2684,7 @@ class SBTopic(ProxyResource): :ivar subscription_count: Number of subscriptions. :vartype subscription_count: int :ivar count_details: Message count details. - :vartype count_details: ~azure.mgmt.servicebus.v2022_01_01_preview.models.MessageCountDetails + :vartype count_details: ~azure.mgmt.servicebus.v2022_01_10_preview.models.MessageCountDetails :ivar default_message_time_to_live: ISO 8601 Default message timespan to live value. This is the duration after which the message expires, starting from when the message is sent to Service Bus. This is the default value used when TimeToLive is not set on a message itself. @@ -2802,7 +2694,7 @@ class SBTopic(ProxyResource): :vartype max_size_in_megabytes: int :ivar max_message_size_in_kilobytes: Maximum size (in KB) of the message payload that can be accepted by the topic. This property is only used in Premium today and default is 1024. - :vartype max_message_size_in_kilobytes: long + :vartype max_message_size_in_kilobytes: int :ivar requires_duplicate_detection: Value indicating if this topic requires duplicate detection. :vartype requires_duplicate_detection: bool @@ -2814,8 +2706,8 @@ class SBTopic(ProxyResource): :vartype enable_batched_operations: bool :ivar status: Enumerates the possible values for the status of a messaging entity. Known values are: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", "Creating", - "Deleting", "Renaming", "Unknown". - :vartype status: str or ~azure.mgmt.servicebus.v2022_01_01_preview.models.EntityStatus + "Deleting", "Renaming", and "Unknown". + :vartype status: str or ~azure.mgmt.servicebus.v2022_01_10_preview.models.EntityStatus :ivar support_ordering: Value that indicates whether the topic supports ordering. :vartype support_ordering: bool :ivar auto_delete_on_idle: ISO 8601 timespan idle interval after which the topic is @@ -2830,42 +2722,45 @@ class SBTopic(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'readonly': True}, - 'system_data': {'readonly': True}, - 'size_in_bytes': {'readonly': True}, - 'created_at': {'readonly': True}, - 'updated_at': {'readonly': True}, - 'accessed_at': {'readonly': True}, - 'subscription_count': {'readonly': True}, - 'count_details': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"readonly": True}, + "system_data": {"readonly": True}, + "size_in_bytes": {"readonly": True}, + "created_at": {"readonly": True}, + "updated_at": {"readonly": True}, + "accessed_at": {"readonly": True}, + "subscription_count": {"readonly": True}, + "count_details": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'size_in_bytes': {'key': 'properties.sizeInBytes', 'type': 'long'}, - 'created_at': {'key': 'properties.createdAt', 'type': 'iso-8601'}, - 'updated_at': {'key': 'properties.updatedAt', 'type': 'iso-8601'}, - 'accessed_at': {'key': 'properties.accessedAt', 'type': 'iso-8601'}, - 'subscription_count': {'key': 'properties.subscriptionCount', 'type': 'int'}, - 'count_details': {'key': 'properties.countDetails', 'type': 'MessageCountDetails'}, - 'default_message_time_to_live': {'key': 'properties.defaultMessageTimeToLive', 'type': 'duration'}, - 'max_size_in_megabytes': {'key': 'properties.maxSizeInMegabytes', 'type': 'int'}, - 'max_message_size_in_kilobytes': {'key': 'properties.maxMessageSizeInKilobytes', 'type': 'long'}, - 'requires_duplicate_detection': {'key': 'properties.requiresDuplicateDetection', 'type': 'bool'}, - 'duplicate_detection_history_time_window': {'key': 'properties.duplicateDetectionHistoryTimeWindow', 'type': 'duration'}, - 'enable_batched_operations': {'key': 'properties.enableBatchedOperations', 'type': 'bool'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'support_ordering': {'key': 'properties.supportOrdering', 'type': 'bool'}, - 'auto_delete_on_idle': {'key': 'properties.autoDeleteOnIdle', 'type': 'duration'}, - 'enable_partitioning': {'key': 'properties.enablePartitioning', 'type': 'bool'}, - 'enable_express': {'key': 'properties.enableExpress', 'type': 'bool'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "size_in_bytes": {"key": "properties.sizeInBytes", "type": "int"}, + "created_at": {"key": "properties.createdAt", "type": "iso-8601"}, + "updated_at": {"key": "properties.updatedAt", "type": "iso-8601"}, + "accessed_at": {"key": "properties.accessedAt", "type": "iso-8601"}, + "subscription_count": {"key": "properties.subscriptionCount", "type": "int"}, + "count_details": {"key": "properties.countDetails", "type": "MessageCountDetails"}, + "default_message_time_to_live": {"key": "properties.defaultMessageTimeToLive", "type": "duration"}, + "max_size_in_megabytes": {"key": "properties.maxSizeInMegabytes", "type": "int"}, + "max_message_size_in_kilobytes": {"key": "properties.maxMessageSizeInKilobytes", "type": "int"}, + "requires_duplicate_detection": {"key": "properties.requiresDuplicateDetection", "type": "bool"}, + "duplicate_detection_history_time_window": { + "key": "properties.duplicateDetectionHistoryTimeWindow", + "type": "duration", + }, + "enable_batched_operations": {"key": "properties.enableBatchedOperations", "type": "bool"}, + "status": {"key": "properties.status", "type": "str"}, + "support_ordering": {"key": "properties.supportOrdering", "type": "bool"}, + "auto_delete_on_idle": {"key": "properties.autoDeleteOnIdle", "type": "duration"}, + "enable_partitioning": {"key": "properties.enablePartitioning", "type": "bool"}, + "enable_express": {"key": "properties.enableExpress", "type": "bool"}, } def __init__( @@ -2894,7 +2789,7 @@ def __init__( :paramtype max_size_in_megabytes: int :keyword max_message_size_in_kilobytes: Maximum size (in KB) of the message payload that can be accepted by the topic. This property is only used in Premium today and default is 1024. - :paramtype max_message_size_in_kilobytes: long + :paramtype max_message_size_in_kilobytes: int :keyword requires_duplicate_detection: Value indicating if this topic requires duplicate detection. :paramtype requires_duplicate_detection: bool @@ -2906,8 +2801,8 @@ def __init__( :paramtype enable_batched_operations: bool :keyword status: Enumerates the possible values for the status of a messaging entity. Known values are: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", "Creating", - "Deleting", "Renaming", "Unknown". - :paramtype status: str or ~azure.mgmt.servicebus.v2022_01_01_preview.models.EntityStatus + "Deleting", "Renaming", and "Unknown". + :paramtype status: str or ~azure.mgmt.servicebus.v2022_01_10_preview.models.EntityStatus :keyword support_ordering: Value that indicates whether the topic supports ordering. :paramtype support_ordering: bool :keyword auto_delete_on_idle: ISO 8601 timespan idle interval after which the topic is @@ -2920,7 +2815,7 @@ def __init__( topic holds a message in memory temporarily before writing it to persistent storage. :paramtype enable_express: bool """ - super(SBTopic, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.size_in_bytes = None self.created_at = None @@ -2941,41 +2836,35 @@ def __init__( self.enable_express = enable_express -class SBTopicListResult(msrest.serialization.Model): +class SBTopicListResult(_serialization.Model): """The response to the List Topics operation. :ivar value: Result of the List Topics operation. - :vartype value: list[~azure.mgmt.servicebus.v2022_01_01_preview.models.SBTopic] + :vartype value: list[~azure.mgmt.servicebus.v2022_01_10_preview.models.SBTopic] :ivar next_link: Link to the next set of results. Not empty if Value contains incomplete list of topics. :vartype next_link: str """ _attribute_map = { - 'value': {'key': 'value', 'type': '[SBTopic]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SBTopic]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["_models.SBTopic"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.SBTopic"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: Result of the List Topics operation. - :paramtype value: list[~azure.mgmt.servicebus.v2022_01_01_preview.models.SBTopic] + :paramtype value: list[~azure.mgmt.servicebus.v2022_01_10_preview.models.SBTopic] :keyword next_link: Link to the next set of results. Not empty if Value contains incomplete list of topics. :paramtype next_link: str """ - super(SBTopicListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class SqlFilter(msrest.serialization.Model): +class SqlFilter(_serialization.Model): """Represents a filter which is a composition of an expression and an action that is executed in the pub/sub pipeline. :ivar sql_expression: The SQL expression. e.g. MyProperty='ABC'. @@ -2989,9 +2878,9 @@ class SqlFilter(msrest.serialization.Model): """ _attribute_map = { - 'sql_expression': {'key': 'sqlExpression', 'type': 'str'}, - 'compatibility_level': {'key': 'compatibilityLevel', 'type': 'int'}, - 'requires_preprocessing': {'key': 'requiresPreprocessing', 'type': 'bool'}, + "sql_expression": {"key": "sqlExpression", "type": "str"}, + "compatibility_level": {"key": "compatibilityLevel", "type": "int"}, + "requires_preprocessing": {"key": "requiresPreprocessing", "type": "bool"}, } def __init__( @@ -2999,7 +2888,7 @@ def __init__( *, sql_expression: Optional[str] = None, compatibility_level: Optional[int] = None, - requires_preprocessing: Optional[bool] = True, + requires_preprocessing: bool = True, **kwargs ): """ @@ -3012,7 +2901,7 @@ def __init__( preprocessing. :paramtype requires_preprocessing: bool """ - super(SqlFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.sql_expression = sql_expression self.compatibility_level = compatibility_level self.requires_preprocessing = requires_preprocessing @@ -3032,9 +2921,9 @@ class SqlRuleAction(Action): """ _attribute_map = { - 'sql_expression': {'key': 'sqlExpression', 'type': 'str'}, - 'compatibility_level': {'key': 'compatibilityLevel', 'type': 'int'}, - 'requires_preprocessing': {'key': 'requiresPreprocessing', 'type': 'bool'}, + "sql_expression": {"key": "sqlExpression", "type": "str"}, + "compatibility_level": {"key": "compatibilityLevel", "type": "int"}, + "requires_preprocessing": {"key": "requiresPreprocessing", "type": "bool"}, } def __init__( @@ -3042,7 +2931,7 @@ def __init__( *, sql_expression: Optional[str] = None, compatibility_level: Optional[int] = None, - requires_preprocessing: Optional[bool] = True, + requires_preprocessing: bool = True, **kwargs ): """ @@ -3055,68 +2944,68 @@ def __init__( preprocessing. :paramtype requires_preprocessing: bool """ - super(SqlRuleAction, self).__init__(sql_expression=sql_expression, compatibility_level=compatibility_level, requires_preprocessing=requires_preprocessing, **kwargs) + super().__init__( + sql_expression=sql_expression, + compatibility_level=compatibility_level, + requires_preprocessing=requires_preprocessing, + **kwargs + ) -class Subnet(msrest.serialization.Model): +class Subnet(_serialization.Model): """Properties supplied for Subnet. All required parameters must be populated in order to send to Azure. - :ivar id: Required. Resource ID of Virtual Network Subnet. + :ivar id: Resource ID of Virtual Network Subnet. Required. :vartype id: str """ _validation = { - 'id': {'required': True}, + "id": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - *, - id: str, - **kwargs - ): + def __init__(self, *, id: str, **kwargs): # pylint: disable=redefined-builtin """ - :keyword id: Required. Resource ID of Virtual Network Subnet. + :keyword id: Resource ID of Virtual Network Subnet. Required. :paramtype id: str """ - super(Subnet, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id -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. Known values are: - "User", "Application", "ManagedIdentity", "Key". + "User", "Application", "ManagedIdentity", and "Key". :vartype created_by_type: str or - ~azure.mgmt.servicebus.v2022_01_01_preview.models.CreatedByType + ~azure.mgmt.servicebus.v2022_01_10_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", "Key". + are: "User", "Application", "ManagedIdentity", and "Key". :vartype last_modified_by_type: str or - ~azure.mgmt.servicebus.v2022_01_01_preview.models.CreatedByType + ~azure.mgmt.servicebus.v2022_01_10_preview.models.CreatedByType :ivar last_modified_at: The type of identity that last modified the resource. :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__( @@ -3134,21 +3023,21 @@ def __init__( :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", "Key". + "User", "Application", "ManagedIdentity", and "Key". :paramtype created_by_type: str or - ~azure.mgmt.servicebus.v2022_01_01_preview.models.CreatedByType + ~azure.mgmt.servicebus.v2022_01_10_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", "Key". + values are: "User", "Application", "ManagedIdentity", and "Key". :paramtype last_modified_by_type: str or - ~azure.mgmt.servicebus.v2022_01_01_preview.models.CreatedByType + ~azure.mgmt.servicebus.v2022_01_10_preview.models.CreatedByType :keyword last_modified_at: The type of identity that last modified the resource. :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 @@ -3157,7 +3046,7 @@ def __init__( self.last_modified_at = last_modified_at -class UserAssignedIdentity(msrest.serialization.Model): +class UserAssignedIdentity(_serialization.Model): """Recognized Dictionary value. Variables are only populated by the server, and will be ignored when sending a request. @@ -3169,27 +3058,23 @@ class UserAssignedIdentity(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(UserAssignedIdentity, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.principal_id = None self.client_id = None -class UserAssignedIdentityProperties(msrest.serialization.Model): +class UserAssignedIdentityProperties(_serialization.Model): """UserAssignedIdentityProperties. :ivar user_assigned_identity: ARM ID of user Identity selected for encryption. @@ -3197,18 +3082,13 @@ class UserAssignedIdentityProperties(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: ARM ID of user Identity selected for encryption. :paramtype user_assigned_identity: str """ - super(UserAssignedIdentityProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.user_assigned_identity = user_assigned_identity diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/_patch.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/models/_patch.py similarity index 99% rename from sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/_patch.py rename to sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/models/_patch.py index 0ad201a8c586e..f7dd32510333d 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/_patch.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/models/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/models/_service_bus_management_client_enums.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/models/_service_bus_management_client_enums.py similarity index 86% rename from sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/models/_service_bus_management_client_enums.py rename to sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/models/_service_bus_management_client_enums.py index b2b24765cf9f7..3bbabd34856a8 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/models/_service_bus_management_client_enums.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/models/_service_bus_management_client_enums.py @@ -11,30 +11,31 @@ class AccessRights(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """AccessRights.""" MANAGE = "Manage" SEND = "Send" LISTEN = "Listen" + class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of identity that created the resource. - """ + """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 - """ + """Default Action for Network Rule Set.""" ALLOW = "Allow" DENY = "Deny" + class EndPointProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Provisioning state of the Private Endpoint Connection. - """ + """Provisioning state of the Private Endpoint Connection.""" CREATING = "Creating" UPDATING = "Updating" @@ -43,9 +44,9 @@ class EndPointProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): CANCELED = "Canceled" FAILED = "Failed" + class EntityStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Entity status. - """ + """Entity status.""" ACTIVE = "Active" DISABLED = "Disabled" @@ -57,114 +58,118 @@ class EntityStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): RENAMING = "Renaming" UNKNOWN = "Unknown" + class FilterType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Rule filter types - """ + """Rule filter types.""" SQL_FILTER = "SqlFilter" CORRELATION_FILTER = "CorrelationFilter" + class KeySource(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Enumerates the possible value of keySource for Encryption - """ + """Enumerates the possible value of keySource for Encryption.""" MICROSOFT_KEY_VAULT = "Microsoft.KeyVault" + class KeyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The access key to regenerate. - """ + """The access key to regenerate.""" PRIMARY_KEY = "PrimaryKey" SECONDARY_KEY = "SecondaryKey" + class ManagedServiceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Type of managed service identity. - """ + """Type of managed service identity.""" SYSTEM_ASSIGNED = "SystemAssigned" USER_ASSIGNED = "UserAssigned" SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" NONE = "None" + class MigrationConfigurationName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """MigrationConfigurationName.""" _DEFAULT = "$default" + class NetworkRuleIPAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The IP Filter Action - """ + """The IP Filter Action.""" ALLOW = "Allow" + class PrivateLinkConnectionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Status of the connection. - """ + """Status of the connection.""" PENDING = "Pending" APPROVED = "Approved" REJECTED = "Rejected" DISCONNECTED = "Disconnected" + class ProvisioningStateDR(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Provisioning state of the Alias(Disaster Recovery configuration) - possible values 'Accepted' - or 'Succeeded' or 'Failed' + or 'Succeeded' or 'Failed'. """ ACCEPTED = "Accepted" SUCCEEDED = "Succeeded" FAILED = "Failed" + class PublicNetworkAccess(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """This determines if traffic is allowed over public network. By default it is enabled. - """ + """This determines if traffic is allowed over public network. By default it is enabled.""" ENABLED = "Enabled" DISABLED = "Disabled" SECURED_BY_PERIMETER = "SecuredByPerimeter" + class PublicNetworkAccessFlag(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """This determines if traffic is allowed over public network. By default it is enabled. - """ + """This determines if traffic is allowed over public network. By default it is enabled.""" ENABLED = "Enabled" DISABLED = "Disabled" + class RoleDisasterRecovery(str, Enum, metaclass=CaseInsensitiveEnumMeta): """role of namespace in GEO DR - possible values 'Primary' or 'PrimaryNotReplicating' or - 'Secondary' + 'Secondary'. """ PRIMARY = "Primary" PRIMARY_NOT_REPLICATING = "PrimaryNotReplicating" SECONDARY = "Secondary" + class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Name of this SKU. - """ + """Name of this SKU.""" BASIC = "Basic" STANDARD = "Standard" PREMIUM = "Premium" + class SkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The billing tier of this particular SKU. - """ + """The billing tier of this particular SKU.""" BASIC = "Basic" STANDARD = "Standard" PREMIUM = "Premium" + class TlsVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The minimum TLS version for the cluster to support, e.g. '1.2' - """ + """The minimum TLS version for the cluster to support, e.g. '1.2'.""" ONE0 = "1.0" ONE1 = "1.1" ONE2 = "1.2" + class UnavailableReason(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the reason for the unavailability of the service. - """ + """Specifies the reason for the unavailability of the service.""" NONE = "None" INVALID_NAME = "InvalidName" diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/operations/__init__.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/operations/__init__.py similarity index 76% rename from sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/operations/__init__.py rename to sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/operations/__init__.py index 5559ccd3746c6..e5431803c533c 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/operations/__init__.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/operations/__init__.py @@ -18,19 +18,20 @@ from ._subscriptions_operations import SubscriptionsOperations from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'NamespacesOperations', - 'PrivateEndpointConnectionsOperations', - 'PrivateLinkResourcesOperations', - 'Operations', - 'DisasterRecoveryConfigsOperations', - 'MigrationConfigsOperations', - 'QueuesOperations', - 'TopicsOperations', - 'RulesOperations', - 'SubscriptionsOperations', + "NamespacesOperations", + "PrivateEndpointConnectionsOperations", + "PrivateLinkResourcesOperations", + "Operations", + "DisasterRecoveryConfigsOperations", + "MigrationConfigsOperations", + "QueuesOperations", + "TopicsOperations", + "RulesOperations", + "SubscriptionsOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/operations/_disaster_recovery_configs_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/operations/_disaster_recovery_configs_operations.py new file mode 100644 index 0000000000000..c6078caef0e49 --- /dev/null +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/operations/_disaster_recovery_configs_operations.py @@ -0,0 +1,1420 @@ +# 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. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +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, namespace_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: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, namespace_name: str, alias: 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: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "alias": _SERIALIZER.url("alias", alias, "str", max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, namespace_name: str, alias: 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: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "alias": _SERIALIZER.url("alias", alias, "str", max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_get_request( + resource_group_name: str, namespace_name: str, alias: 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: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "alias": _SERIALIZER.url("alias", alias, "str", max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_break_pairing_request( + resource_group_name: str, namespace_name: str, alias: 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: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/breakPairing", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "alias": _SERIALIZER.url("alias", alias, "str", max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_fail_over_request( + resource_group_name: str, namespace_name: str, alias: 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: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/failover", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "alias": _SERIALIZER.url("alias", alias, "str", max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_authorization_rules_request( + resource_group_name: str, namespace_name: str, alias: 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: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "alias": _SERIALIZER.url("alias", alias, "str", max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_authorization_rule_request( + resource_group_name: str, + namespace_name: str, + alias: str, + authorization_rule_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: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules/{authorizationRuleName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "alias": _SERIALIZER.url("alias", alias, "str", max_length=50, min_length=1), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_keys_request( + resource_group_name: str, + namespace_name: str, + alias: str, + authorization_rule_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: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules/{authorizationRuleName}/listKeys", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "alias": _SERIALIZER.url("alias", alias, "str", max_length=50, min_length=1), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_check_name_availability_request( + resource_group_name: str, namespace_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: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/CheckNameAvailability", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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 DisasterRecoveryConfigsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.servicebus.v2022_01_10_preview.ServiceBusManagementClient`'s + :attr:`disaster_recovery_configs` 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, namespace_name: str, **kwargs: Any + ) -> Iterable["_models.ArmDisasterRecovery"]: + """Gets all Alias(Disaster Recovery configurations). + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ArmDisasterRecovery or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2022_01_10_preview.models.ArmDisasterRecovery] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.ArmDisasterRecoveryListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + namespace_name=namespace_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) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ArmDisasterRecoveryListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs" + } + + @overload + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + alias: str, + parameters: _models.ArmDisasterRecovery, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> Optional[_models.ArmDisasterRecovery]: + """Creates or updates a new Alias(Disaster Recovery configuration). + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: str + :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). + Required. + :type parameters: ~azure.mgmt.servicebus.v2022_01_10_preview.models.ArmDisasterRecovery + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ArmDisasterRecovery or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.ArmDisasterRecovery or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + alias: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> Optional[_models.ArmDisasterRecovery]: + """Creates or updates a new Alias(Disaster Recovery configuration). + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: str + :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). + Required. + :type 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: ArmDisasterRecovery or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.ArmDisasterRecovery or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + alias: str, + parameters: Union[_models.ArmDisasterRecovery, IO], + **kwargs: Any + ) -> Optional[_models.ArmDisasterRecovery]: + """Creates or updates a new Alias(Disaster Recovery configuration). + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: str + :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). Is + either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2022_01_10_preview.models.ArmDisasterRecovery 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: ArmDisasterRecovery or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.ArmDisasterRecovery or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + 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: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.ArmDisasterRecovery]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ArmDisasterRecovery") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + alias=alias, + subscription_id=self._config.subscription_id, + 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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("ArmDisasterRecovery", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}" + } + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, namespace_name: str, alias: str, **kwargs: Any + ) -> None: + """Deletes an Alias(Disaster Recovery configuration). + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: 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, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + alias=alias, + subscription_id=self._config.subscription_id, + 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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # 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.ErrorResponse, 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.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}" + } + + @distributed_trace + def get( + self, resource_group_name: str, namespace_name: str, alias: str, **kwargs: Any + ) -> _models.ArmDisasterRecovery: + """Retrieves Alias(Disaster Recovery configuration) for primary or secondary namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ArmDisasterRecovery or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.ArmDisasterRecovery + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.ArmDisasterRecovery] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + alias=alias, + 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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ArmDisasterRecovery", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}" + } + + @distributed_trace + def break_pairing( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, namespace_name: str, alias: str, **kwargs: Any + ) -> None: + """This operation disables the Disaster Recovery and stops replicating changes from primary to + secondary namespaces. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: 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, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_break_pairing_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + alias=alias, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.break_pairing.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + break_pairing.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/breakPairing" + } + + @overload + def fail_over( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + namespace_name: str, + alias: str, + parameters: Optional[_models.FailoverProperties] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Invokes GEO DR failover and reconfigure the alias to point to the secondary namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: str + :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). + Default value is None. + :type parameters: ~azure.mgmt.servicebus.v2022_01_10_preview.models.FailoverProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default 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: + """ + + @overload + def fail_over( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + namespace_name: str, + alias: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Invokes GEO DR failover and reconfigure the alias to point to the secondary namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: str + :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). + Default value is None. + :type 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: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def fail_over( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + namespace_name: str, + alias: str, + parameters: Optional[Union[_models.FailoverProperties, IO]] = None, + **kwargs: Any + ) -> None: + """Invokes GEO DR failover and reconfigure the alias to point to the secondary namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: str + :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). Is + either a model type or a IO type. Default value is None. + :type parameters: ~azure.mgmt.servicebus.v2022_01_10_preview.models.FailoverProperties 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: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + 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: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + if parameters is not None: + _json = self._serialize.body(parameters, "FailoverProperties") + else: + _json = None + + request = build_fail_over_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + alias=alias, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.fail_over.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + fail_over.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/failover" + } + + @distributed_trace + def list_authorization_rules( + self, resource_group_name: str, namespace_name: str, alias: str, **kwargs: Any + ) -> Iterable["_models.SBAuthorizationRule"]: + """Gets the authorization rules for a namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either SBAuthorizationRule or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2022_01_10_preview.models.SBAuthorizationRule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.SBAuthorizationRuleListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_authorization_rules_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + alias=alias, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_authorization_rules.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("SBAuthorizationRuleListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_authorization_rules.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules" + } + + @distributed_trace + def get_authorization_rule( + self, resource_group_name: str, namespace_name: str, alias: str, authorization_rule_name: str, **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Gets an authorization rule for a namespace by rule name. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBAuthorizationRule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.SBAuthorizationRule] = kwargs.pop("cls", None) + + request = build_get_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + alias=alias, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_authorization_rule.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SBAuthorizationRule", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules/{authorizationRuleName}" + } + + @distributed_trace + def list_keys( + self, resource_group_name: str, namespace_name: str, alias: str, authorization_rule_name: str, **kwargs: Any + ) -> _models.AccessKeys: + """Gets the primary and secondary connection strings for the namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AccessKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.AccessKeys] = kwargs.pop("cls", None) + + request = build_list_keys_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + alias=alias, + authorization_rule_name=authorization_rule_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("AccessKeys", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules/{authorizationRuleName}/listKeys" + } + + @overload + def check_name_availability( + self, + resource_group_name: str, + namespace_name: str, + parameters: _models.CheckNameAvailability, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters to check availability of the given namespace name. Required. + :type parameters: ~azure.mgmt.servicebus.v2022_01_10_preview.models.CheckNameAvailability + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckNameAvailabilityResult or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters to check availability of the given namespace name. Required. + :type 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: CheckNameAvailabilityResult or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_name_availability( + self, + resource_group_name: str, + namespace_name: str, + parameters: Union[_models.CheckNameAvailability, IO], + **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters to check availability of the given namespace name. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2022_01_10_preview.models.CheckNameAvailability 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: CheckNameAvailabilityResult or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + 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: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CheckNameAvailabilityResult] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "CheckNameAvailability") + + request = build_check_name_availability_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + 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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + check_name_availability.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/CheckNameAvailability" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/operations/_migration_configs_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/operations/_migration_configs_operations.py new file mode 100644 index 0000000000000..205c6980f28ff --- /dev/null +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/operations/_migration_configs_operations.py @@ -0,0 +1,923 @@ +# 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. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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 + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +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, namespace_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: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_and_start_migration_request( + resource_group_name: str, + namespace_name: str, + config_name: Union[str, _models.MigrationConfigurationName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "configName": _SERIALIZER.url("config_name", config_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, + namespace_name: str, + config_name: Union[str, _models.MigrationConfigurationName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "configName": _SERIALIZER.url("config_name", config_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_get_request( + resource_group_name: str, + namespace_name: str, + config_name: Union[str, _models.MigrationConfigurationName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "configName": _SERIALIZER.url("config_name", config_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_complete_migration_request( + resource_group_name: str, + namespace_name: str, + config_name: Union[str, _models.MigrationConfigurationName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/upgrade", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "configName": _SERIALIZER.url("config_name", config_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_revert_request( + resource_group_name: str, + namespace_name: str, + config_name: Union[str, _models.MigrationConfigurationName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/revert", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "configName": _SERIALIZER.url("config_name", config_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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) + + +class MigrationConfigsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.servicebus.v2022_01_10_preview.ServiceBusManagementClient`'s + :attr:`migration_configs` 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, namespace_name: str, **kwargs: Any + ) -> Iterable["_models.MigrationConfigProperties"]: + """Gets all migrationConfigurations. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either MigrationConfigProperties or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2022_01_10_preview.models.MigrationConfigProperties] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.MigrationConfigListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + namespace_name=namespace_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) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("MigrationConfigListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations" + } + + def _create_and_start_migration_initial( + self, + resource_group_name: str, + namespace_name: str, + config_name: Union[str, _models.MigrationConfigurationName], + parameters: Union[_models.MigrationConfigProperties, IO], + **kwargs: Any + ) -> Optional[_models.MigrationConfigProperties]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + 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: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.MigrationConfigProperties]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "MigrationConfigProperties") + + request = build_create_and_start_migration_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + config_name=config_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_and_start_migration_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("MigrationConfigProperties", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_and_start_migration_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}" + } + + @overload + def begin_create_and_start_migration( + self, + resource_group_name: str, + namespace_name: str, + config_name: Union[str, _models.MigrationConfigurationName], + parameters: _models.MigrationConfigProperties, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.MigrationConfigProperties]: + """Creates Migration configuration and starts migration of entities from Standard to Premium + namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param config_name: The configuration name. Should always be "$default". "$default" Required. + :type config_name: str or + ~azure.mgmt.servicebus.v2022_01_10_preview.models.MigrationConfigurationName + :param parameters: Parameters required to create Migration Configuration. Required. + :type parameters: ~azure.mgmt.servicebus.v2022_01_10_preview.models.MigrationConfigProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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 MigrationConfigProperties or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.servicebus.v2022_01_10_preview.models.MigrationConfigProperties] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_and_start_migration( + self, + resource_group_name: str, + namespace_name: str, + config_name: Union[str, _models.MigrationConfigurationName], + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.MigrationConfigProperties]: + """Creates Migration configuration and starts migration of entities from Standard to Premium + namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param config_name: The configuration name. Should always be "$default". "$default" Required. + :type config_name: str or + ~azure.mgmt.servicebus.v2022_01_10_preview.models.MigrationConfigurationName + :param parameters: Parameters required to create Migration Configuration. Required. + :type 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 + :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 MigrationConfigProperties or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.servicebus.v2022_01_10_preview.models.MigrationConfigProperties] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_and_start_migration( + self, + resource_group_name: str, + namespace_name: str, + config_name: Union[str, _models.MigrationConfigurationName], + parameters: Union[_models.MigrationConfigProperties, IO], + **kwargs: Any + ) -> LROPoller[_models.MigrationConfigProperties]: + """Creates Migration configuration and starts migration of entities from Standard to Premium + namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param config_name: The configuration name. Should always be "$default". "$default" Required. + :type config_name: str or + ~azure.mgmt.servicebus.v2022_01_10_preview.models.MigrationConfigurationName + :param parameters: Parameters required to create Migration Configuration. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2022_01_10_preview.models.MigrationConfigProperties + 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 MigrationConfigProperties or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.servicebus.v2022_01_10_preview.models.MigrationConfigProperties] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.MigrationConfigProperties] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_and_start_migration_initial( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + config_name=config_name, + parameters=parameters, + 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("MigrationConfigProperties", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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) # type: ignore + + begin_create_and_start_migration.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}" + } + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + namespace_name: str, + config_name: Union[str, _models.MigrationConfigurationName], + **kwargs: Any + ) -> None: + """Deletes a MigrationConfiguration. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param config_name: The configuration name. Should always be "$default". "$default" Required. + :type config_name: str or + ~azure.mgmt.servicebus.v2022_01_10_preview.models.MigrationConfigurationName + :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, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + config_name=config_name, + subscription_id=self._config.subscription_id, + 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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # 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.ErrorResponse, 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.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}" + } + + @distributed_trace + def get( + self, + resource_group_name: str, + namespace_name: str, + config_name: Union[str, _models.MigrationConfigurationName], + **kwargs: Any + ) -> _models.MigrationConfigProperties: + """Retrieves Migration Config. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param config_name: The configuration name. Should always be "$default". "$default" Required. + :type config_name: str or + ~azure.mgmt.servicebus.v2022_01_10_preview.models.MigrationConfigurationName + :keyword callable cls: A custom type or function that will be passed the direct response + :return: MigrationConfigProperties or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.MigrationConfigProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.MigrationConfigProperties] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + config_name=config_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("MigrationConfigProperties", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}" + } + + @distributed_trace + def complete_migration( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + namespace_name: str, + config_name: Union[str, _models.MigrationConfigurationName], + **kwargs: Any + ) -> None: + """This operation Completes Migration of entities by pointing the connection strings to Premium + namespace and any entities created after the operation will be under Premium Namespace. + CompleteMigration operation will fail when entity migration is in-progress. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param config_name: The configuration name. Should always be "$default". "$default" Required. + :type config_name: str or + ~azure.mgmt.servicebus.v2022_01_10_preview.models.MigrationConfigurationName + :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, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_complete_migration_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + config_name=config_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.complete_migration.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + complete_migration.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/upgrade" + } + + @distributed_trace + def revert( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + namespace_name: str, + config_name: Union[str, _models.MigrationConfigurationName], + **kwargs: Any + ) -> None: + """This operation reverts Migration. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param config_name: The configuration name. Should always be "$default". "$default" Required. + :type config_name: str or + ~azure.mgmt.servicebus.v2022_01_10_preview.models.MigrationConfigurationName + :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, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_revert_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + config_name=config_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.revert.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + revert.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/revert" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/operations/_namespaces_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/operations/_namespaces_operations.py new file mode 100644 index 0000000000000..242502abbbd3f --- /dev/null +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/operations/_namespaces_operations.py @@ -0,0 +1,2367 @@ +# 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. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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 + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +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, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/namespaces") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, namespace_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: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, namespace_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: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_get_request( + resource_group_name: str, namespace_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: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, namespace_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: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_create_or_update_network_rule_set_request( + resource_group_name: str, namespace_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: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_get_network_rule_set_request( + resource_group_name: str, namespace_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: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_network_rule_sets_request( + resource_group_name: str, namespace_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: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_authorization_rules_request( + resource_group_name: str, namespace_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: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_authorization_rule_request( + resource_group_name: str, namespace_name: str, authorization_rule_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: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_authorization_rule_request( + resource_group_name: str, namespace_name: str, authorization_rule_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: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_get_authorization_rule_request( + resource_group_name: str, namespace_name: str, authorization_rule_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: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_keys_request( + resource_group_name: str, namespace_name: str, authorization_rule_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: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/listKeys", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_regenerate_keys_request( + resource_group_name: str, namespace_name: str, authorization_rule_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: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/regenerateKeys", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_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: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/CheckNameAvailability" + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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 NamespacesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.servicebus.v2022_01_10_preview.ServiceBusManagementClient`'s + :attr:`namespaces` 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.SBNamespace"]: + """Gets all the available namespaces within the subscription, irrespective of the resource groups. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either SBNamespace or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2022_01_10_preview.models.SBNamespace] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.SBNamespaceListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + 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) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("SBNamespaceListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/namespaces"} + + @distributed_trace + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.SBNamespace"]: + """Gets the available namespaces within a resource group. + + :param resource_group_name: Name of the Resource group within the Azure subscription. 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 SBNamespace or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2022_01_10_preview.models.SBNamespace] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.SBNamespaceListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + 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) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("SBNamespaceListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # 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.ErrorResponse, 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.ServiceBus/namespaces" + } + + def _create_or_update_initial( + self, resource_group_name: str, namespace_name: str, parameters: Union[_models.SBNamespace, IO], **kwargs: Any + ) -> Optional[_models.SBNamespace]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + 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: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.SBNamespace]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBNamespace") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + 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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("SBNamespace", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("SBNamespace", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}" + } + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + namespace_name: str, + parameters: _models.SBNamespace, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.SBNamespace]: + """Creates or updates a service namespace. Once created, this namespace's resource manifest is + immutable. This operation is idempotent. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to create a namespace resource. Required. + :type parameters: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SBNamespace + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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 SBNamespace or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.servicebus.v2022_01_10_preview.models.SBNamespace] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.SBNamespace]: + """Creates or updates a service namespace. Once created, this namespace's resource manifest is + immutable. This operation is idempotent. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to create a namespace resource. Required. + :type 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 + :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 SBNamespace or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.servicebus.v2022_01_10_preview.models.SBNamespace] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, resource_group_name: str, namespace_name: str, parameters: Union[_models.SBNamespace, IO], **kwargs: Any + ) -> LROPoller[_models.SBNamespace]: + """Creates or updates a service namespace. Once created, this namespace's resource manifest is + immutable. This operation is idempotent. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to create a namespace resource. Is either a model type + or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SBNamespace 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 SBNamespace or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.servicebus.v2022_01_10_preview.models.SBNamespace] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SBNamespace] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + parameters=parameters, + 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("SBNamespace", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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) # type: ignore + + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + namespace_name=namespace_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}" + } + + @distributed_trace + def begin_delete(self, resource_group_name: str, namespace_name: str, **kwargs: Any) -> LROPoller[None]: + """Deletes an existing namespace. This operation also removes all associated resources under the + namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_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 None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + namespace_name=namespace_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): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}" + } + + @distributed_trace + def get(self, resource_group_name: str, namespace_name: str, **kwargs: Any) -> _models.SBNamespace: + """Gets a description for the specified namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBNamespace or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SBNamespace + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.SBNamespace] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SBNamespace", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}" + } + + @overload + def update( + self, + resource_group_name: str, + namespace_name: str, + parameters: _models.SBNamespaceUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> Optional[_models.SBNamespace]: + """Updates a service namespace. Once created, this namespace's resource manifest is immutable. + This operation is idempotent. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to update a namespace resource. Required. + :type parameters: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SBNamespaceUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBNamespace or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SBNamespace or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> Optional[_models.SBNamespace]: + """Updates a service namespace. Once created, this namespace's resource manifest is immutable. + This operation is idempotent. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to update a namespace resource. Required. + :type 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: SBNamespace or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SBNamespace or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + namespace_name: str, + parameters: Union[_models.SBNamespaceUpdateParameters, IO], + **kwargs: Any + ) -> Optional[_models.SBNamespace]: + """Updates a service namespace. Once created, this namespace's resource manifest is immutable. + This operation is idempotent. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to update a namespace resource. Is either a model type + or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SBNamespaceUpdateParameters + 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: SBNamespace or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SBNamespace or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + 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: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.SBNamespace]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBNamespaceUpdateParameters") + + request = build_update_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("SBNamespace", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("SBNamespace", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}" + } + + @overload + def create_or_update_network_rule_set( + self, + resource_group_name: str, + namespace_name: str, + parameters: _models.NetworkRuleSet, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.NetworkRuleSet: + """Create or update NetworkRuleSet for a Namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: The Namespace IpFilterRule. Required. + :type parameters: ~azure.mgmt.servicebus.v2022_01_10_preview.models.NetworkRuleSet + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: NetworkRuleSet or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.NetworkRuleSet + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_network_rule_set( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.NetworkRuleSet: + """Create or update NetworkRuleSet for a Namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: The Namespace IpFilterRule. Required. + :type 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: NetworkRuleSet or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.NetworkRuleSet + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update_network_rule_set( + self, + resource_group_name: str, + namespace_name: str, + parameters: Union[_models.NetworkRuleSet, IO], + **kwargs: Any + ) -> _models.NetworkRuleSet: + """Create or update NetworkRuleSet for a Namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: The Namespace IpFilterRule. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2022_01_10_preview.models.NetworkRuleSet 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: NetworkRuleSet or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.NetworkRuleSet + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + 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: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.NetworkRuleSet] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "NetworkRuleSet") + + request = build_create_or_update_network_rule_set_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update_network_rule_set.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("NetworkRuleSet", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update_network_rule_set.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default" + } + + @distributed_trace + def get_network_rule_set( + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> _models.NetworkRuleSet: + """Gets NetworkRuleSet for a Namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: NetworkRuleSet or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.NetworkRuleSet + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.NetworkRuleSet] = kwargs.pop("cls", None) + + request = build_get_network_rule_set_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_network_rule_set.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("NetworkRuleSet", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_network_rule_set.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default" + } + + @distributed_trace + def list_network_rule_sets( + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> Iterable["_models.NetworkRuleSet"]: + """Gets list of NetworkRuleSet for a Namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either NetworkRuleSet or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2022_01_10_preview.models.NetworkRuleSet] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.NetworkRuleSetListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_network_rule_sets_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_network_rule_sets.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("NetworkRuleSetListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_network_rule_sets.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets" + } + + @distributed_trace + def list_authorization_rules( + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> Iterable["_models.SBAuthorizationRule"]: + """Gets the authorization rules for a namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either SBAuthorizationRule or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2022_01_10_preview.models.SBAuthorizationRule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.SBAuthorizationRuleListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_authorization_rules_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_authorization_rules.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("SBAuthorizationRuleListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_authorization_rules.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules" + } + + @overload + def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: _models.SBAuthorizationRule, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates or updates an authorization rule for a namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Required. + :type parameters: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SBAuthorizationRule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBAuthorizationRule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates or updates an authorization rule for a namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Required. + :type 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: SBAuthorizationRule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: Union[_models.SBAuthorizationRule, IO], + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates or updates an authorization rule for a namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SBAuthorizationRule 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: SBAuthorizationRule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + 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: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SBAuthorizationRule] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBAuthorizationRule") + + request = build_create_or_update_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update_authorization_rule.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SBAuthorizationRule", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}" + } + + @distributed_trace + def delete_authorization_rule( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, namespace_name: str, authorization_rule_name: str, **kwargs: Any + ) -> None: + """Deletes a namespace authorization rule. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_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, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_authorization_rule.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}" + } + + @distributed_trace + def get_authorization_rule( + self, resource_group_name: str, namespace_name: str, authorization_rule_name: str, **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Gets an authorization rule for a namespace by rule name. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBAuthorizationRule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.SBAuthorizationRule] = kwargs.pop("cls", None) + + request = build_get_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_authorization_rule.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SBAuthorizationRule", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}" + } + + @distributed_trace + def list_keys( + self, resource_group_name: str, namespace_name: str, authorization_rule_name: str, **kwargs: Any + ) -> _models.AccessKeys: + """Gets the primary and secondary connection strings for the namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AccessKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.AccessKeys] = kwargs.pop("cls", None) + + request = build_list_keys_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + authorization_rule_name=authorization_rule_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("AccessKeys", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/listKeys" + } + + @overload + def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: _models.RegenerateAccessKeyParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AccessKeys: + """Regenerates the primary or secondary connection strings for the namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Required. + :type parameters: + ~azure.mgmt.servicebus.v2022_01_10_preview.models.RegenerateAccessKeyParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AccessKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AccessKeys: + """Regenerates the primary or secondary connection strings for the namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Required. + :type 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: AccessKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: Union[_models.RegenerateAccessKeyParameters, IO], + **kwargs: Any + ) -> _models.AccessKeys: + """Regenerates the primary or secondary connection strings for the namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Is either a model + type or a IO type. Required. + :type parameters: + ~azure.mgmt.servicebus.v2022_01_10_preview.models.RegenerateAccessKeyParameters 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: AccessKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + 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: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AccessKeys] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RegenerateAccessKeyParameters") + + request = build_regenerate_keys_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.regenerate_keys.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("AccessKeys", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + regenerate_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/regenerateKeys" + } + + @overload + def check_name_availability( + self, parameters: _models.CheckNameAvailability, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param parameters: Parameters to check availability of the given namespace name. Required. + :type parameters: ~azure.mgmt.servicebus.v2022_01_10_preview.models.CheckNameAvailability + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckNameAvailabilityResult or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param parameters: Parameters to check availability of the given namespace name. Required. + :type 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: CheckNameAvailabilityResult or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_name_availability( + self, parameters: Union[_models.CheckNameAvailability, IO], **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param parameters: Parameters to check availability of the given namespace name. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2022_01_10_preview.models.CheckNameAvailability 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: CheckNameAvailabilityResult or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + 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: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CheckNameAvailabilityResult] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "CheckNameAvailability") + + 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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + check_name_availability.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/CheckNameAvailability" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/operations/_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/operations/_operations.py similarity index 58% rename from sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/operations/_operations.py rename to sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/operations/_operations.py index c63bde8af4500..a074c98f52f3a 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/operations/_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/operations/_operations.py @@ -6,11 +6,18 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,38 +27,40 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request -T = TypeVar('T') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +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: + +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-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.ServiceBus/operations") # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + class Operations: """ @@ -59,7 +68,7 @@ class Operations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.servicebus.v2022_01_01_preview.ServiceBusManagementClient`'s + :class:`~azure.mgmt.servicebus.v2022_01_10_preview.ServiceBusManagementClient`'s :attr:`operations` attribute. """ @@ -72,52 +81,59 @@ def __init__(self, *args, **kwargs): 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 ServiceBus 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.paging.ItemPaged[~azure.mgmt.servicebus.v2022_01_01_preview.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2022_01_10_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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + 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'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: - - request = build_list_request( - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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.url = self._client.format_url(request.url) request.method = "GET" return request @@ -125,16 +141,14 @@ 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) + list_of_elem = cls(list_of_elem) # type: ignore 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -145,8 +159,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.ServiceBus/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.ServiceBus/operations"} diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/operations/_patch.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/operations/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_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/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/operations/_private_endpoint_connections_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/operations/_private_endpoint_connections_operations.py new file mode 100644 index 0000000000000..3343b136b37a2 --- /dev/null +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/operations/_private_endpoint_connections_operations.py @@ -0,0 +1,670 @@ +# 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. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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 + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +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, namespace_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: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, + namespace_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: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/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", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, + namespace_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: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_get_request( + resource_group_name: str, + namespace_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: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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 PrivateEndpointConnectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.servicebus.v2022_01_10_preview.ServiceBusManagementClient`'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, namespace_name: str, **kwargs: Any + ) -> Iterable["_models.PrivateEndpointConnection"]: + """Gets the available PrivateEndpointConnections within a namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either PrivateEndpointConnection or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2022_01_10_preview.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + namespace_name=namespace_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) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections" + } + + @overload + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + private_endpoint_connection_name: str, + parameters: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Creates or updates PrivateEndpointConnections of service namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param private_endpoint_connection_name: The PrivateEndpointConnection name. Required. + :type private_endpoint_connection_name: str + :param parameters: Parameters supplied to update Status of PrivateEndPoint Connection to + namespace resource. Required. + :type parameters: ~azure.mgmt.servicebus.v2022_01_10_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 + :return: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + private_endpoint_connection_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Creates or updates PrivateEndpointConnections of service namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param private_endpoint_connection_name: The PrivateEndpointConnection name. Required. + :type private_endpoint_connection_name: str + :param parameters: Parameters supplied to update Status of PrivateEndPoint Connection to + namespace resource. Required. + :type 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: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + private_endpoint_connection_name: str, + parameters: Union[_models.PrivateEndpointConnection, IO], + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Creates or updates PrivateEndpointConnections of service namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param private_endpoint_connection_name: The PrivateEndpointConnection name. Required. + :type private_endpoint_connection_name: str + :param parameters: Parameters supplied to update Status of PrivateEndPoint Connection to + namespace resource. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2022_01_10_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 + :return: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + 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: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PrivateEndpointConnection") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + namespace_name=namespace_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.create_or_update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, namespace_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + namespace_name=namespace_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}" + } + + @distributed_trace + def begin_delete( + self, resource_group_name: str, namespace_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes an existing Private Endpoint Connection. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param private_endpoint_connection_name: The PrivateEndpointConnection name. 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 None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + namespace_name=namespace_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): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}" + } + + @distributed_trace + def get( + self, resource_group_name: str, namespace_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Gets a description for the specified Private Endpoint Connection. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param private_endpoint_connection_name: The PrivateEndpointConnection name. 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.servicebus.v2022_01_10_preview.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # 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.ErrorResponse, 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.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/operations/_private_link_resources_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/operations/_private_link_resources_operations.py similarity index 55% rename from sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/operations/_private_link_resources_operations.py rename to sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/operations/_private_link_resources_operations.py index 890123c2a6137..789b7f9747cdf 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/operations/_private_link_resources_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/operations/_private_link_resources_operations.py @@ -6,11 +6,17 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Optional, TypeVar -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest @@ -19,48 +25,54 @@ 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') + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +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, - namespace_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_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-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateLinkResources") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateLinkResources", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + class PrivateLinkResourcesOperations: """ @@ -68,7 +80,7 @@ class PrivateLinkResourcesOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.servicebus.v2022_01_01_preview.ServiceBusManagementClient`'s + :class:`~azure.mgmt.servicebus.v2022_01_10_preview.ServiceBusManagementClient`'s :attr:`private_link_resources` attribute. """ @@ -81,54 +93,53 @@ def __init__(self, *args, **kwargs): 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, - namespace_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, **kwargs: Any ) -> _models.PrivateLinkResourcesListResult: """Gets lists of resources that supports Privatelinks. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateLinkResourcesListResult, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.PrivateLinkResourcesListResult - :raises: ~azure.core.exceptions.HttpResponseError + :return: PrivateLinkResourcesListResult or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.PrivateLinkResourcesListResult + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) 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-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateLinkResourcesListResult] + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.PrivateLinkResourcesListResult] = kwargs.pop("cls", None) - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -136,12 +147,13 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateLinkResourcesListResult', pipeline_response) + deserialized = self._deserialize("PrivateLinkResourcesListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateLinkResources"} # type: ignore - + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateLinkResources" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/operations/_queues_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/operations/_queues_operations.py new file mode 100644 index 0000000000000..257fe5c760209 --- /dev/null +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/operations/_queues_operations.py @@ -0,0 +1,1510 @@ +# 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. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_authorization_rules_request( + resource_group_name: str, namespace_name: str, queue_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: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_authorization_rule_request( + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_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: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, "str", min_length=1), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_authorization_rule_request( + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_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: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, "str", min_length=1), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_get_authorization_rule_request( + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_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: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, "str", min_length=1), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_keys_request( + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_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: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/ListKeys", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, "str", min_length=1), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_regenerate_keys_request( + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_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: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/regenerateKeys", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, "str", min_length=1), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_by_namespace_request( + resource_group_name: str, + namespace_name: str, + subscription_id: str, + *, + skip: Optional[int] = None, + top: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", maximum=1000, minimum=0) + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int", maximum=1000, minimum=1) + + # 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, namespace_name: str, queue_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: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, namespace_name: str, queue_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: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_get_request( + resource_group_name: str, namespace_name: str, queue_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: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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 QueuesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.servicebus.v2022_01_10_preview.ServiceBusManagementClient`'s + :attr:`queues` 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_authorization_rules( + self, resource_group_name: str, namespace_name: str, queue_name: str, **kwargs: Any + ) -> Iterable["_models.SBAuthorizationRule"]: + """Gets all authorization rules for a queue. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either SBAuthorizationRule or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2022_01_10_preview.models.SBAuthorizationRule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.SBAuthorizationRuleListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_authorization_rules_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_authorization_rules.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("SBAuthorizationRuleListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_authorization_rules.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules" + } + + @overload + def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: _models.SBAuthorizationRule, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates an authorization rule for a queue. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Required. + :type parameters: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SBAuthorizationRule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBAuthorizationRule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates an authorization rule for a queue. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Required. + :type 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: SBAuthorizationRule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: Union[_models.SBAuthorizationRule, IO], + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates an authorization rule for a queue. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SBAuthorizationRule 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: SBAuthorizationRule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + 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: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SBAuthorizationRule] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBAuthorizationRule") + + request = build_create_or_update_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update_authorization_rule.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SBAuthorizationRule", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}" + } + + @distributed_trace + def delete_authorization_rule( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + **kwargs: Any + ) -> None: + """Deletes a queue authorization rule. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_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, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_authorization_rule.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}" + } + + @distributed_trace + def get_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Gets an authorization rule for a queue by rule name. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBAuthorizationRule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.SBAuthorizationRule] = kwargs.pop("cls", None) + + request = build_get_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_authorization_rule.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SBAuthorizationRule", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}" + } + + @distributed_trace + def list_keys( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + **kwargs: Any + ) -> _models.AccessKeys: + """Primary and secondary connection strings to the queue. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AccessKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.AccessKeys] = kwargs.pop("cls", None) + + request = build_list_keys_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + authorization_rule_name=authorization_rule_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("AccessKeys", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/ListKeys" + } + + @overload + def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: _models.RegenerateAccessKeyParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AccessKeys: + """Regenerates the primary or secondary connection strings to the queue. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Required. + :type parameters: + ~azure.mgmt.servicebus.v2022_01_10_preview.models.RegenerateAccessKeyParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AccessKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AccessKeys: + """Regenerates the primary or secondary connection strings to the queue. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Required. + :type 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: AccessKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: Union[_models.RegenerateAccessKeyParameters, IO], + **kwargs: Any + ) -> _models.AccessKeys: + """Regenerates the primary or secondary connection strings to the queue. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Is either a model + type or a IO type. Required. + :type parameters: + ~azure.mgmt.servicebus.v2022_01_10_preview.models.RegenerateAccessKeyParameters 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: AccessKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + 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: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AccessKeys] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RegenerateAccessKeyParameters") + + request = build_regenerate_keys_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.regenerate_keys.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("AccessKeys", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + regenerate_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/regenerateKeys" + } + + @distributed_trace + def list_by_namespace( + self, + resource_group_name: str, + namespace_name: str, + skip: Optional[int] = None, + top: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.SBQueue"]: + """Gets the queues within a namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param skip: Skip is only used if a previous operation returned a partial result. If a previous + response contains a nextLink element, the value of the nextLink element will include a skip + parameter that specifies a starting point to use for subsequent calls. Default value is None. + :type skip: int + :param top: May be used to limit the number of results to the most recent N usageDetails. + Default value is None. + :type top: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either SBQueue or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2022_01_10_preview.models.SBQueue] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.SBQueueListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_namespace_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + skip=skip, + top=top, + api_version=api_version, + template_url=self.list_by_namespace.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("SBQueueListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_namespace.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues" + } + + @overload + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + parameters: _models.SBQueue, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBQueue: + """Creates or updates a Service Bus queue. This operation is idempotent. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param parameters: Parameters supplied to create or update a queue resource. Required. + :type parameters: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SBQueue + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBQueue or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SBQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBQueue: + """Creates or updates a Service Bus queue. This operation is idempotent. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param parameters: Parameters supplied to create or update a queue resource. Required. + :type 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: SBQueue or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SBQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + parameters: Union[_models.SBQueue, IO], + **kwargs: Any + ) -> _models.SBQueue: + """Creates or updates a Service Bus queue. This operation is idempotent. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param parameters: Parameters supplied to create or update a queue resource. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SBQueue 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: SBQueue or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SBQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + 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: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SBQueue] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBQueue") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + subscription_id=self._config.subscription_id, + 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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SBQueue", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}" + } + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, namespace_name: str, queue_name: str, **kwargs: Any + ) -> None: + """Deletes a queue from the specified namespace in a resource group. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_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, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + subscription_id=self._config.subscription_id, + 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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # 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.ErrorResponse, 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.ServiceBus/namespaces/{namespaceName}/queues/{queueName}" + } + + @distributed_trace + def get(self, resource_group_name: str, namespace_name: str, queue_name: str, **kwargs: Any) -> _models.SBQueue: + """Returns a description for the specified queue. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBQueue or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SBQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.SBQueue] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SBQueue", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/operations/_rules_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/operations/_rules_operations.py new file mode 100644 index 0000000000000..27957739cb436 --- /dev/null +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/operations/_rules_operations.py @@ -0,0 +1,686 @@ +# 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. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +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_subscriptions_request( + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + subscription_id: str, + *, + skip: Optional[int] = None, + top: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, "str", max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", maximum=1000, minimum=0) + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int", maximum=1000, minimum=1) + + # 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, + namespace_name: str, + topic_name: str, + subscription_name: str, + rule_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: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, "str", max_length=50, min_length=1), + "ruleName": _SERIALIZER.url("rule_name", rule_name, "str", max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, + namespace_name: str, + topic_name: str, + subscription_name: str, + rule_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: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, "str", max_length=50, min_length=1), + "ruleName": _SERIALIZER.url("rule_name", rule_name, "str", max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_get_request( + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + rule_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: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, "str", max_length=50, min_length=1), + "ruleName": _SERIALIZER.url("rule_name", rule_name, "str", max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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 RulesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.servicebus.v2022_01_10_preview.ServiceBusManagementClient`'s + :attr:`rules` 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_subscriptions( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + skip: Optional[int] = None, + top: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.Rule"]: + """List all the rules within given topic-subscription. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param skip: Skip is only used if a previous operation returned a partial result. If a previous + response contains a nextLink element, the value of the nextLink element will include a skip + parameter that specifies a starting point to use for subsequent calls. Default value is None. + :type skip: int + :param top: May be used to limit the number of results to the most recent N usageDetails. + Default value is None. + :type top: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Rule or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2022_01_10_preview.models.Rule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.RuleListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscriptions_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_name=subscription_name, + subscription_id=self._config.subscription_id, + skip=skip, + top=top, + api_version=api_version, + template_url=self.list_by_subscriptions.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("RuleListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_subscriptions.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules" + } + + @overload + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + rule_name: str, + parameters: _models.Rule, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Rule: + """Creates a new rule and updates an existing rule. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param rule_name: The rule name. Required. + :type rule_name: str + :param parameters: Parameters supplied to create a rule. Required. + :type parameters: ~azure.mgmt.servicebus.v2022_01_10_preview.models.Rule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Rule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.Rule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Rule: + """Creates a new rule and updates an existing rule. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param rule_name: The rule name. Required. + :type rule_name: str + :param parameters: Parameters supplied to create a rule. Required. + :type 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: Rule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.Rule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + rule_name: str, + parameters: Union[_models.Rule, IO], + **kwargs: Any + ) -> _models.Rule: + """Creates a new rule and updates an existing rule. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param rule_name: The rule name. Required. + :type rule_name: str + :param parameters: Parameters supplied to create a rule. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.servicebus.v2022_01_10_preview.models.Rule 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: Rule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.Rule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + 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: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Rule] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Rule") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_name=subscription_name, + rule_name=rule_name, + subscription_id=self._config.subscription_id, + 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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Rule", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}" + } + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + rule_name: str, + **kwargs: Any + ) -> None: + """Deletes an existing rule. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param rule_name: The rule name. Required. + :type rule_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, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_name=subscription_name, + rule_name=rule_name, + subscription_id=self._config.subscription_id, + 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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # 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.ErrorResponse, 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.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}" + } + + @distributed_trace + def get( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + rule_name: str, + **kwargs: Any + ) -> _models.Rule: + """Retrieves the description for the specified rule. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param rule_name: The rule name. Required. + :type rule_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Rule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.Rule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.Rule] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_name=subscription_name, + rule_name=rule_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Rule", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/operations/_subscriptions_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/operations/_subscriptions_operations.py new file mode 100644 index 0000000000000..cc33f9f764660 --- /dev/null +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/operations/_subscriptions_operations.py @@ -0,0 +1,647 @@ +# 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. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +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_topic_request( + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_id: str, + *, + skip: Optional[int] = None, + top: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", maximum=1000, minimum=0) + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int", maximum=1000, minimum=1) + + # 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, + namespace_name: str, + topic_name: str, + subscription_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: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, "str", max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, + namespace_name: str, + topic_name: str, + subscription_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: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, "str", max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_get_request( + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_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: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, "str", max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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 SubscriptionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.servicebus.v2022_01_10_preview.ServiceBusManagementClient`'s + :attr:`subscriptions` 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_topic( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + skip: Optional[int] = None, + top: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.SBSubscription"]: + """List all the subscriptions under a specified topic. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param skip: Skip is only used if a previous operation returned a partial result. If a previous + response contains a nextLink element, the value of the nextLink element will include a skip + parameter that specifies a starting point to use for subsequent calls. Default value is None. + :type skip: int + :param top: May be used to limit the number of results to the most recent N usageDetails. + Default value is None. + :type top: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either SBSubscription or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2022_01_10_preview.models.SBSubscription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.SBSubscriptionListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_topic_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_id=self._config.subscription_id, + skip=skip, + top=top, + api_version=api_version, + template_url=self.list_by_topic.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("SBSubscriptionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_topic.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions" + } + + @overload + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + parameters: _models.SBSubscription, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBSubscription: + """Creates a topic subscription. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param parameters: Parameters supplied to create a subscription resource. Required. + :type parameters: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SBSubscription + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBSubscription or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SBSubscription + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBSubscription: + """Creates a topic subscription. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param parameters: Parameters supplied to create a subscription resource. Required. + :type 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: SBSubscription or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SBSubscription + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + parameters: Union[_models.SBSubscription, IO], + **kwargs: Any + ) -> _models.SBSubscription: + """Creates a topic subscription. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param parameters: Parameters supplied to create a subscription resource. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SBSubscription 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: SBSubscription or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SBSubscription + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + 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: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SBSubscription] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBSubscription") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_name=subscription_name, + subscription_id=self._config.subscription_id, + 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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SBSubscription", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}" + } + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, namespace_name: str, topic_name: str, subscription_name: str, **kwargs: Any + ) -> None: + """Deletes a subscription from the specified topic. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_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, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_name=subscription_name, + subscription_id=self._config.subscription_id, + 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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # 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.ErrorResponse, 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.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}" + } + + @distributed_trace + def get( + self, resource_group_name: str, namespace_name: str, topic_name: str, subscription_name: str, **kwargs: Any + ) -> _models.SBSubscription: + """Returns a subscription description for the specified topic. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBSubscription or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SBSubscription + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.SBSubscription] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_name=subscription_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SBSubscription", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/operations/_topics_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/operations/_topics_operations.py new file mode 100644 index 0000000000000..32254d6154d46 --- /dev/null +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/operations/_topics_operations.py @@ -0,0 +1,1510 @@ +# 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. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_authorization_rules_request( + resource_group_name: str, namespace_name: str, topic_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: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_authorization_rule_request( + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_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: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_get_authorization_rule_request( + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_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: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_delete_authorization_rule_request( + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_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: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_keys_request( + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_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: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/ListKeys", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_regenerate_keys_request( + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_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: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/regenerateKeys", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", authorization_rule_name, "str", max_length=50, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_by_namespace_request( + resource_group_name: str, + namespace_name: str, + subscription_id: str, + *, + skip: Optional[int] = None, + top: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", maximum=1000, minimum=0) + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int", maximum=1000, minimum=1) + + # 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, namespace_name: str, topic_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: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, namespace_name: str, topic_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: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_get_request( + resource_group_name: str, namespace_name: str, topic_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: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str", max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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 TopicsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.servicebus.v2022_01_10_preview.ServiceBusManagementClient`'s + :attr:`topics` 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_authorization_rules( + self, resource_group_name: str, namespace_name: str, topic_name: str, **kwargs: Any + ) -> Iterable["_models.SBAuthorizationRule"]: + """Gets authorization rules for a topic. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either SBAuthorizationRule or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2022_01_10_preview.models.SBAuthorizationRule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.SBAuthorizationRuleListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_authorization_rules_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_authorization_rules.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("SBAuthorizationRuleListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_authorization_rules.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules" + } + + @overload + def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: _models.SBAuthorizationRule, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates an authorization rule for the specified topic. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Required. + :type parameters: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SBAuthorizationRule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBAuthorizationRule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates an authorization rule for the specified topic. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Required. + :type 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: SBAuthorizationRule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: Union[_models.SBAuthorizationRule, IO], + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates an authorization rule for the specified topic. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SBAuthorizationRule 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: SBAuthorizationRule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + 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: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SBAuthorizationRule] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBAuthorizationRule") + + request = build_create_or_update_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update_authorization_rule.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SBAuthorizationRule", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}" + } + + @distributed_trace + def get_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Returns the specified authorization rule. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBAuthorizationRule or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.SBAuthorizationRule] = kwargs.pop("cls", None) + + request = build_get_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_authorization_rule.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SBAuthorizationRule", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}" + } + + @distributed_trace + def delete_authorization_rule( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + **kwargs: Any + ) -> None: + """Deletes a topic authorization rule. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_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, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_authorization_rule.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}" + } + + @distributed_trace + def list_keys( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + **kwargs: Any + ) -> _models.AccessKeys: + """Gets the primary and secondary connection strings for the topic. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AccessKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.AccessKeys] = kwargs.pop("cls", None) + + request = build_list_keys_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + authorization_rule_name=authorization_rule_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("AccessKeys", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/ListKeys" + } + + @overload + def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: _models.RegenerateAccessKeyParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AccessKeys: + """Regenerates primary or secondary connection strings for the topic. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Required. + :type parameters: + ~azure.mgmt.servicebus.v2022_01_10_preview.models.RegenerateAccessKeyParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AccessKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AccessKeys: + """Regenerates primary or secondary connection strings for the topic. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Required. + :type 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: AccessKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: Union[_models.RegenerateAccessKeyParameters, IO], + **kwargs: Any + ) -> _models.AccessKeys: + """Regenerates primary or secondary connection strings for the topic. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Is either a model + type or a IO type. Required. + :type parameters: + ~azure.mgmt.servicebus.v2022_01_10_preview.models.RegenerateAccessKeyParameters 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: AccessKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + 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: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AccessKeys] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RegenerateAccessKeyParameters") + + request = build_regenerate_keys_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.regenerate_keys.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("AccessKeys", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + regenerate_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/regenerateKeys" + } + + @distributed_trace + def list_by_namespace( + self, + resource_group_name: str, + namespace_name: str, + skip: Optional[int] = None, + top: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.SBTopic"]: + """Gets all the topics in a namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param skip: Skip is only used if a previous operation returned a partial result. If a previous + response contains a nextLink element, the value of the nextLink element will include a skip + parameter that specifies a starting point to use for subsequent calls. Default value is None. + :type skip: int + :param top: May be used to limit the number of results to the most recent N usageDetails. + Default value is None. + :type top: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either SBTopic or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2022_01_10_preview.models.SBTopic] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.SBTopicListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_namespace_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + skip=skip, + top=top, + api_version=api_version, + template_url=self.list_by_namespace.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("SBTopicListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_namespace.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics" + } + + @overload + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + parameters: _models.SBTopic, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBTopic: + """Creates a topic in the specified namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param parameters: Parameters supplied to create a topic resource. Required. + :type parameters: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SBTopic + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBTopic or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SBTopic + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBTopic: + """Creates a topic in the specified namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param parameters: Parameters supplied to create a topic resource. Required. + :type 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: SBTopic or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SBTopic + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + parameters: Union[_models.SBTopic, IO], + **kwargs: Any + ) -> _models.SBTopic: + """Creates a topic in the specified namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param parameters: Parameters supplied to create a topic resource. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SBTopic 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: SBTopic or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SBTopic + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + 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: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SBTopic] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBTopic") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_id=self._config.subscription_id, + 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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SBTopic", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}" + } + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, namespace_name: str, topic_name: str, **kwargs: Any + ) -> None: + """Deletes a topic from the specified namespace and resource group. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_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, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_id=self._config.subscription_id, + 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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # 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.ErrorResponse, 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.ServiceBus/namespaces/{namespaceName}/topics/{topicName}" + } + + @distributed_trace + def get(self, resource_group_name: str, namespace_name: str, topic_name: str, **kwargs: Any) -> _models.SBTopic: + """Returns a description for the specified topic. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBTopic or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_10_preview.models.SBTopic + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) + cls: ClsType[_models.SBTopic] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # 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.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SBTopic", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}" + } diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/py.typed b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/py.typed similarity index 100% rename from sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/py.typed rename to sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_10_preview/py.typed